Help with multiple arguements

function getArea(width, length, unit) {
    const area = width * length;
    return `${area} + ${unit}`;
}

This above is my code, I was wondering why when i try to input
getArea = (2, 8, ‘ft’)
the console logs only the string ‘ft’ instead of running 16 ft?

Based on your code it should output ‘16 + ft’

Can you show more code? Like where the console log happens? Your function shouldn’t be logging anything on the console, based on the code you provided so far.

When i try to hit the console in the browser, when i type in [ getArea = (10, 20) alone ] it provides me with the calculated answer of 20 but when i type in the [ getArea = (10,20, ‘string of any unit’,

the ‘string of any unit’ only pops up.

This was just a section in a tutorial I have seen and tried to run the simple line of code myself but it does’nt even pop up so im kinda bummed.

This is not a call to the function. A call to the function would look like:

getArea(2, 8, 'ft')

Thank you very much! I tried it and works flawlessly, I suppose i should pay more attention to my spaces.

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