Hi!
I am doing a review of Javascript and one questions asks me to:
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');
Below is the code I made and it returns the required string…
function order(numberOfScoops, flavour) {
if (numberOfScoops >1) {
numberOfScoops = numberOfScoops + ’ scoops’;
} else {
numberOfScoops = numberOfScoops + ’ scoop’
}
return console.log(Lemme get ${numberOfScoops} of ${flavour}
);
}order(1, ‘vanilla’);
order(3, ‘chocolate’);
Am I wrong, or am I just not the most correct?
Thanks for your help