Hallo, ik ben bezig met oefeningen op codeacademy te maken maar bij unit 4: while loops in javascript begrijp ik niet. Zou iemand me dat kunnen uitleggen en ook functions in javascript. Hier zijn een paar voorbeelden:
Functions met if en else
var quarter = function(number) {
return number / 5;
};
if (quarter(4) % 3 === 1 ) {
console.log("The statement is true");
} else {
console.log("The statement is false");
}
while loops:
var coinFace = Math.floor(Math.random() * 2);
while(coinFace === 0){
console.log("Heads! Flipping again...");
var coinFace = Math.floor(Math.random() * 2);
}
console.log("Tails! Done flipping.");
Functions met if en else
var quarter = function(number) {
return number / 5;
};
if (quarter(4) % 3 === 1 ) {
console.log("The statement is true");
} else {
console.log("The statement is false");
}
while loops:
var coinFace = Math.floor(Math.random() * 2);
while(coinFace === 0){
console.log("Heads! Flipping again...");
var coinFace = Math.floor(Math.random() * 2);
}
console.log("Tails! Done flipping.");