Stuck on quiz ice cream question, please help. Javascript order() function, if else, etc

Hi Everyone,

I’ve been stuck on this for a while (sorry, having trouble linking):

Define an **order() function that announces your ice cream order.

It should take two arguments: the number of scoops and the flavor. It should return the order in this format: "Lemme get [number] scoops of [flavor]!" It should use “scoop” when number is 1 and “scoops” for anything greater.

For example:

// Returns "Lemme get 1 scoop of vanilla!"
order(1, ‘vanilla’);
// Returns "Lemme get 3 scoops of chocolate!"
order(3, ‘chocolate’);

Here’s what I have so far, but I think I’m way off:

function iceCream (number, flavor)
  if (number = 1) {
  return "Lemme get 1 scoop of" + flavor; + "!"}
 else {return "Lemme get" + number + "scoops of" + flavor + "!"}
}

It keeps telling me I have syntax errors when I try to use the if statement, and then it also tells me that flavor isn’t defined. I’m so confused!

Please help! Thanks so much.

Hello @halesrus7, welcome to the forums!

You might want to check the = sign here:

= is an assignment operator. Equality operators are either == or ===. See here for more on that.

Should you have a semicolon (;) here?

When you define a function, after the definition, you have an opening curly brace {, and at the end of the function, a closing curly brace }:

function x(){
//code
}

Is that what you have?
I hope this helps!

THANK YOU SOOOO MUCH!

1 Like