misk-jsd2 / 03-conditionals-and-loops

0 stars 10 forks source link

ziyad al mansouri #23

Closed ziyadSman closed 5 years ago

ziyadSman commented 5 years ago

// assignment 1 (bottle) for (var i=100;i>=0;i--){ num=i; if (num!=1&&num!=0){ console.log(num,"bottles of beer on the wall",num, "bottles of beer Take one down and pass it around", --num ,"bottles of beer on the wall"); }else if (num==1){console.log("1 bottle of beer on the wall, 1 bottle of beer. Take one down and pass it around, no more bottles of beer on the wall")} else console.log("No more bottles of beer on the wall, no more bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall")}

// assignment 2 (addresses) var streetno = [60,70,15,36]; var streetname = ['olaya', 'king aziz','king fahad','king salman']; var cityname= ['riyadh','jeddah','dammam','madenah','makka']; var zipcode=[33513,11501,15921,77618];

var randstreetno= streetno[Math.floor(Math.random() streetno.length)]; var randstreetnam= streetname[Math.floor(Math.random() streetname.length)]; var randcityname= cityname[Math.floor(Math.random() cityname.length)]; var randzip= zipcode[Math.floor(Math.random() zipcode.length)];

var randaddress = randstreetno+" "+randstreetnam+ "street,"+ randcityname+ ", "+ randzip; console.log(randaddress);

morojAlh commented 5 years ago

Good job Ziyad 👍🏼 In assignment 1 output: 2 'bottles of beer on the wall' 2 'bottles of beer Take one down and pass it around' 1 'bottles of beer on the wall Here the output should be 1 'bottle

Also, I like what you did here streetno[Math.floor(Math.random()* streetno.length)], generate the random number based on length of the array.