dimanche 4 août 2019

How to assign a boolean to variable1 if variable2 meets certain criteria

Home work problem where i am given two variables, typeOfPizza and lovesPizza, and dependant on whether typeOfPiza is 'pepperoni' or olives', assign lovesPizza to true or false respectively.

I tried manipulating code, using if/else, if/if/else, if/else if/ else...

function exerciseThree(typeOfPizza){
  let lovesPizza;

  // In this exercise, you will be given a variable, it will be called:         typeOfPizza
  // You are also given another variable called: lovesPizza;
  // Using an if/else statement assign lovesPizza to true if typeOfPizza is 'pepperoni', assign it to false if it is 'olives'

I expect the output to be lovesPizza is true if typeOfPizza is 'pepperoni', and lovesPizza to be false if typeOfPizza is 'olives'. instead i get:

Should return true if typeOfPizza is 'pepperoni', and false if it is 'olives' Expected undefined to be false.

Aucun commentaire:

Enregistrer un commentaire