Guys hi ı have a undefined problem

function Identity(firstname,lastname,age) {

return"Hello my name is " + firstname + lastname+ "I am "+age+ "years old"


console.log(Identity('Galip Kaya 20 '))

when ı write this code ı got this result.

Hello my name is Galip Kaya 20 undefinedI am undefinedyears old

Hello, and welcome to the forums!

Your function is expecting 3 arguments:

function Identity(firstname,lastname,age) 

You’re calling the function with only one argument, so only firstname has a value.

You used

Identity('Galip Kaya 20 ')

but you mean to use

Identity('Galip', 'Kaya', 20)

That way your function will receive a value for fristname, lastname, and age and can use them in the function separately.

When a function doesn’t receive an argument for one of the parameters, JavaScript will use undefined

1 Like

Thanks a lot ^^ ı

I am grateful.