-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |