IceCream Exercise

I am doing the exercise of ice cream scoops and flavor. I think I did right, well the answer was logged correct but I am not sure if I wrote the correct/logical way. I know there is an arrow function that makes it shorter, but I am not there yet, so I am writing on the long way.

function order(number, flavor){
  if(number >= 2){
console.log(`Lemme get ${number} scoops of ${flavor} !`);
  }else{
    console.log(`Lemme get 1 scoop of ${flavor} !`);
  }
}

order(2,"chocolate");

Thank you,
Gus

you could provide a default argument for number parameter. So if people want 1 scoop, they only have to order the flavor.

not sure if this has been covered, so here is the documentation:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/default_parameters

Besides arrow functions which you’ve already mentioned, have you encountered ternary operators yet?

Oh I saw default argument, I didn’t thought to use it. Thank you!

I didn’t see yet, but just googled and that would be very helpful. Thank you!