Help!Confuse with the result with console.log and return


I m new to programming, i m confuse why i get different results when i use console.log instead of return. when i used return, i only get one result which is 12 but when i used console, i get 12 and a 4 below.

Oops, try again. It looks like your perimeterBox function doesn't return the correct perimeter (4) for a width of 1 and a length of 1.

var perimeterBox=function(length,width)
{  console.log (length +length + width + width);};


printing to console has the effect of showing text.. in the console. It does nothing else, so unless that's specifically what you want to do then that's not what you want to use.

return exits the current function and gives the result to the caller which can do whatever it wants with the result, including printing it


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.