Blog

Joys of JavaScript (UW Coding Bootcamp Session)
Posted on June 1, 2019 in JavaScript by Matt Jennings

Primitive Variables

Types of primitive values:

  • Numbers
  • Strings
  • Booleans
  • undefined
  • null
  • Symbol() (ES6)

confirm vs prompt

// confirm only returns a Boolean of true or false
// depending on if I click "Ok" in a popup (true)
// or "Cancel" in a popup (false)
var doYouLikeSush = confirm("Do you like sushi");
console.log(doYouLikeSushi);
// Output is true if clicking "Ok" 
// or false if clicking "Cancel"

// prompt returns a value
// that is entered into a popup window
var kindOfFoodYouLike = prompt('What kind of food do you like');
console.log(kindOfFoodYouLike);
// Output is "pizza" if I put
// "pizza" in pop up window

 

Leave a Reply