Home > Blockchain >  Normal function in javascript isnt working
Normal function in javascript isnt working

Time:09-26

I'm reaaally really new with javascript, and I was following this documentation on anonimous functions, which seemed to worked perfectly, but when I tried a code for a normal one that was supposed to be simple it just. didnt work. I'm trying to just get console log that says Hola plus the name that was already established before.

nombre = "Carolina"; 
function saludo(nombre){
return console.log("Hola: "   saludo);
}
saludo(nombre);

and the result in console log is just

Hola: function saludo(_nombre){ return console.log("Hola: " saludo);.

Seemed to work perfectly for the guy on the documentation and im losing my mind, sorry if its too simple, im really starting to code and have no one to ask for help :(!

CodePudding user response:

You are referring to the function in the line return console.log("Hola: " saludo), change it to nombre as it is the function parameter.

nombre = "Carolina"; 
function saludo(nombre) {
    return console.log("Hola: "   nombre);
}
saludo(nombre);

Output

Carolina
  • Related