Skip to content

Instantly share code, notes, and snippets.

@pvanallen
Last active October 9, 2020 03:06
Show Gist options
  • Save pvanallen/07d38d5d25f1e00b3527162b871c5039 to your computer and use it in GitHub Desktop.
Save pvanallen/07d38d5d25f1e00b3527162b871c5039 to your computer and use it in GitHub Desktop.
Series of code snippets to practice with
// 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