A question of coding


#1


Hey, I'm not actually stuck but I did have a question about the following exercise. I was originally trying to code this function using the console.log function but when I did that, it would give me two printouts: one of the perimeter and one of just the width. I soon realized I was supposed to use the return function and everything went smoothly from there, but why does the console.log function produce those two printouts?

https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/2/1?curriculum_id=506324b3a7dffd00020bf661


I included the lines of code in question, but I did end up using the return function instead.


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


#2

I believe you will find an answer here:


#3

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