Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
// Write your solution below.
// ====================================================================

//or parsefloat
var firstNumber = prompt('Please input a number');
firstNumber = parseInt(firstNumber);


var secondNumber = prompt('Please input another number');
secondNumber = parseInt(secondNumber);

var difference = (firstNumber - secondNumber);
difference = Math.abs(difference);
console.log(difference);



Expand Down Expand Up @@ -61,7 +72,13 @@
// Write your solution below.
// =======================================================================

var x = Math.floor((Math.random() * 10) + 1);
var y = parseInt(prompt('please input an input an integer'))

if (x === y ) {
console.log('Match');
}
else console.log('Try Again');



Expand Down Expand Up @@ -89,7 +106,7 @@
// Write your solution below.
// =====================================================================


console.log(Math.random().toString(36).replace('0.', '') );



Expand All @@ -115,9 +132,20 @@
// Write your solution below.
// ====================================================================

var testArray = [1, 2, 4, 8, 16, 32, 64, 128];

function shuffle(a) {
var j, x, i;
for (i = a.length - 1; i > 0; i--) {
j = Math.floor(Math.random() * (i + 1));
x = a[i];
a[i] = a[j];
a[j] = x;
}
return a;
}

var testArray = [1, 2, 4, 8, 16, 32, 64, 128];
shuffle(testArray);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and direct! A suggestion on coding practices though? Try to use more descriptive variable names for readability. It can be important when working in teams. Any increase in file size is completely negated when we start using optimization tools prior to deployment anyway.




Expand Down