Wa maxey Iterations ? Iterations wa loop ama wareeg, waxaana uu naga caawiya inaan so saarno macluumaad tiro badan, si nadaamsan walibo la fahmi karo.
Waxaa jiro sedex nooc oo loop ah waxa eyna kala yihin:
Dhamaantod isku shaqo ayey qabtaan waxa kaliya eyku kala duwan yihin wa sida ey shaqada u qabanayan. Sidokale waxaad loop ku sameen kartaa Arrays.
Waxaad record gareysay ama aad keydisey macluumaad, kadib waxaad rabtaa inaad so bandhigto macluumaadkas, Loops waxa ey ku fududeneysa inaad so daabacdo macluumaadkas tirada badan adigo qorayo less code yacni lines code ah oona badneen.
for (initializer; condition; action) {
//some data...
}
initializer wa inaad u sheegta loop ka mesha uu shaqada ka bilaabayo, condition wa mesha checking ka hubinta eyka dhaceyso, action inta conditon uu true/haa yahay ficilka lasameenayo.
const people = ["ahmed", "adam", "asad"];
for (let person = 0; person < 3; person++) {
console.log(people[person]);
}
Tusaalahan kore waxa uu so saari doona magacyada: ahmed, adam, asad.
Hadii loops eysan jiri laheen, oo aad rabto inaad so saarto xogtaan kor ku xusan okale waxaad ku qasbanaan laheed inaan qorto lines tiro badan.
const people = ["ahmed", "adam", "asad"];
console.log(people[0]); // ahmed
console.log(people[1]); // adam
console.log(people[2]); // asad
let z = 0; // initiazer
while (condtion) {
z++; // action
}
const people = ["ahmed", "adam", "asad"];
let x = 0;
while (x < people.length) {
console.log(people[x]);
x++;
}
Aqriste waxaan rajeenaya inaad wax badan ka fahantey qormaadan.
Next Lesson >