Ask coding questions

← Back to all posts
stuck can't figure it out...new to coding
divability1 (1)

Can somebody please help with this code? I am not understanding how to write this JS. It's for an exercise, so we're just console.log'ing in the code block. But I'm seriously stuck. Please help.

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'

// Please write your answer in the line above.
return lovesPizza;
}

Commentshotnewtop
Ov3R10rd (48)

one way you could do this is
if(typeOfPizza=='pepperoni'){
lovesPizza==truel;
}else{
lovesPizza==false;
}

Hope this helps! :)

Ov3R10rd (48)

@Ov3R10rd Also, if you want to do a specific parameter for your second one, I recomend else if.

divability1 (1)

Thanks a bunch. I'll try when i get home. Hope it works too! @Ov3R10rd

divability1 (1)

It worked. Only one = for lovesPizza = true. Thank u so much. I was making it way more difficult!
@Ov3R10rd

Ov3R10rd (48)

no problem! glad to help. @divability1

Vandesm14 (692)

Did you try writing the if statement?

divability1 (1)

Yes. Confused how to writefor 2 variables...pepperonior olives
@Vandesm14

Vandesm14 (692)

@divability1 "Pepperoni" and "Olives" are the two values that typeOfPizza can take. You need to write an if statement that determines if typeOfPizza is equal to "Pepperoni" or "Olives"