Javascript function declaration - codecademy says it is incorrect however it is returning the required string.... help!

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 :smile:

Try running the following code. Why is the output different?

function funcOne() {
    return 'Hello';
}

function funcTwo() {
    return console.log('Hello');
}

let retValOne = funcOne();
console.log(retValOne);
// 'Hello'

let retValTwo = funcTwo();
// 'Hello'
console.log(retValTwo);
// undefined
Hint

Have a look at the return value of the console.log method. See the “Return value” in the documentation for the method: console: log() method - Web APIs | MDN

The specifications want you to return a string. They don’t want you to return the return value of console.log