diff --git a/01week/javascripting/chance.js b/01week/javascripting/chance.js new file mode 100644 index 000000000..d26e933ee --- /dev/null +++ b/01week/javascripting/chance.js @@ -0,0 +1,21 @@ +'use strict'; +/**Pick a random student from this class +*Store names in a variable-array +*generate a random number, less than amount in class +*apply index to array +*from that array, pick a random name +*return a name +**/ + +const studentArray = ['dude','person','thing']; + +function randomNumberInRange(top, bottom) { + return Math.floor (Math.random()*(1 + top - bottom ))+bottom; +} + + +function generateRandomName(){ + const index = randomNumberInRange(studentArray.length-1, 0); + return studentArray[index]; +} +console.log(generateRandomName()); diff --git a/01week/javascripting/data-types.js b/01week/javascripting/data-types.js new file mode 100644 index 000000000..70f48a894 --- /dev/null +++ b/01week/javascripting/data-types.js @@ -0,0 +1,61 @@ + +function returnDate(){ + const date=new Date(); + return date;} + +console.log(returnDate()) + + +function NtoS() { + const num = 7; + const n = num.toString(); + return (n); +} + +console.log(NtoS()); + +function stuff(){ + const s = parseInt('77'); + return (s); +} +console.log(stuff()); + + +function add(){ + const sum = 3+4; + return (sum); +} +console.log (add()); + + + +function twotrue(){ + const x=5 + const y=5 + if (x===y){ + return('true'); + } + +} +console.log(twotrue()); + +function onetrue(){ + const x2=5 + const y2='5' + if (x2===5 && y2!==5){ + return('1true'); + } +} +console.log(onetrue()); + +console.log(typeof x); +console.log(typeof y2); + +function allfalse(){ + const x3=5 + const y3='5' + if (x3!=='5' && y3!==5){ + return('false'); + } +} +console.log(allfalse());