diff --git a/4-simple-data-manipulation/1.js b/4-simple-data-manipulation/1.js new file mode 100644 index 0000000..c182845 --- /dev/null +++ b/4-simple-data-manipulation/1.js @@ -0,0 +1,34 @@ +// Learn what each of the operators (listed below) does, +// then write a program that sets each of two variables to a number, +// then outputs the result of each of these operators on those numbers. +// Make sure you can describe, in your own words, what each operator does. +// + +// - +// / +// * +// % +// == +// <, >, <=, >= + +var numOne = 1 +var numTwo = 2 + +console.log(numOne + numTwo) + +console.log(numOne - numTwo) + +console.log(numOne / numTwo) + +console.log(numOne * numTwo) + +console.log(numOne % numTwo) + +console.log(numOne == numTwo) + +console.log(numOne < numTwo) + +console.log(numOne > numTwo) + +console.log(numOne <= numTwo) + +console.log(numOne >= numTwo) \ No newline at end of file diff --git a/4-simple-data-manipulation/2.js b/4-simple-data-manipulation/2.js new file mode 100644 index 0000000..55455f3 --- /dev/null +++ b/4-simple-data-manipulation/2.js @@ -0,0 +1,8 @@ +// Write a program that sets each of two variables to a number, then displays the integer quotient and integer result to the screen, like so: 7 / 3 = 2 r 1. (Hint: parseInt() in JavaScript is like to_i in Ruby.) + +var numOne = 7 +var numTwo = 3 + +console.log(parseInt(numOne / numTwo)) + +console.log(numOne % numTwo) \ No newline at end of file diff --git a/4-simple-data-manipulation/3.js b/4-simple-data-manipulation/3.js new file mode 100644 index 0000000..8141f46 --- /dev/null +++ b/4-simple-data-manipulation/3.js @@ -0,0 +1,5 @@ +// Write a program that sets a variable to a string, then return the ALLCAPS version of that string. (In Ruby, you would have used upcase.) + +var string = "This is a string." + +console.log(string.toLocaleUpperCase()); \ No newline at end of file diff --git a/4-simple-data-manipulation/4.js b/4-simple-data-manipulation/4.js new file mode 100644 index 0000000..2f57b98 --- /dev/null +++ b/4-simple-data-manipulation/4.js @@ -0,0 +1,16 @@ +// Learn how to use the compound assignment operators. What do they do? +// += +// -= +// *= +// /= +// %= + +var num = 1 + +console.log(num) +console.log(num--) +console.log(num++) +console.log(num += 3) +console.log(num *= 3) +console.log(num /= 3) +console.log(num %= 3) \ No newline at end of file