Last active
October 9, 2020 03:06
-
-
Save pvanallen/07d38d5d25f1e00b3527162b871c5039 to your computer and use it in GitHub Desktop.
Series of code snippets to practice with
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
// viewing errors | |
// this line has an error in it | |
let myVar, = 10; | |
// using the console | |
console.log("hi"); | |
console.log(myVar); | |
// variable set a value + case | |
// this line has an error in it | |
myvar = 20; | |
// concatenating strings | |
console.log("hi" + myVar); | |
// using variables | |
let tripMiles = 200; | |
let gallonsConsumed = 5; | |
let costPerGallon = 3.5; | |
let mpg = tripMiles/gallonsConsumed; | |
let tripCost = gallonsConsumed * costPerGallon; | |
if (mpg >= 40) { | |
console.log("Yay!"); | |
} else { | |
console.log("Boo!"); | |
} | |
console.log("MPG = " + mpg); | |
console.log("Cost of trip = $" + tripCost); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment