Hello, I have to do an exercise of functions that I tried to do in a thousand ways and it keeps throwing me an error. I tell you the slogan: "I wrote a function FullNameLength that takes a first name and a last name as a parameter and returns their total length, counting an extra space to separate both." What I did was
code
function longitudNombreCompleto('Cosme', 'Fulanito') {
return longitudNombreCompleto.length
}
and I no longer know how to approach it because even this last resolution throws me an error, that is, it is wrong. I would greatly appreciate the help.
the structure of the function is poorly elaborated, apparently it's your first steps in Javascript huh? I recommend you read this article that deals with the topic of creating functions: https://developer.mozilla.org/es/docs/Web/JavaScript/Guide/Functions
In the case of your question, your function would look like this plus minus:
What did I basically do? I take the 2 parameters introduced to the function, I concatenate them (put them together) and return the size of them.
Since we have the elaborated function, we can use it in the following way, in this case I introduce the strings "Juan" and "Alfonso":
Go deeper and review more on the subject so that you can perform the exercises correctly. Comment if you made it. Cheers!
As Rodny says, your function is poorly crafted.
He explained it very well. A small correction in the code so that you have the extra space to separate the names: