misk-jsd2 / 03-conditionals-and-loops

0 stars 10 forks source link

Abdullah Almalki #27

Closed aalmalki closed 5 years ago

aalmalki commented 5 years ago

Bottles of cokes:

for (var i = 99 ; i>=0; i--){ if (i == 2){ console.log(i + "bottles of coke on the wall," + i + "bottles of coke. Take one down and pass it around," + (i-1) + " bottle of coke on the wall.");

} else if (i == 1) { console.log(i+" bottle of coke on the wall, "+i+" bottle of coke. Take one down and pass it around, no more bottles of coke on the wall.");
} else if (i == 0) { console.log("No more bottles of coke on the wall, no more bottles of coke. Go to the store and buy some more, 99 bottles of coke on the wall.");
} else { console.log(i+" bottles of coke on the wall, "+i+" bottles of coke. Take one down and pass it around, "+(i-1)+" bottles of coke on the wall.");
}


Random Address:

var streetNums = [2548,2154,1521,8957]; var streetNames = ['King St.', 'Highway St.', 'Moonlight St.', 'Wonder St.']; var citiesNames = ['Jeddah', 'Dubai', 'New York','Amsterdam']; var zipCodes = [3321,5897,4574,1215];

var randomStreetNum = streetNums[Math.floor(Math.random() streetNums.length)]; var randomStreetName = streetNames[Math.floor(Math.random() streetNames.length)]; var randomCityName = citiesNames[Math.floor(Math.random() citiesNames.length)]; var randomZizCode = zipCodes[Math.floor(Math.random() zipCodes.length)];

console.log(randomStreetNum); console.log(randomStreetName); console.log(randomCityName); console.log(randomZizCode);

morojAlh commented 5 years ago

Good job Abdullah 👍🏼 I like what you did here streetNums[Math.floor(Math.random() * streetNums.length)], generate the random number based on length of the array.