2
I’m taking Javascript course on Codecademy
, I did the function, it is returned what the exercise asks, but not step.
2
I’m taking Javascript course on Codecademy
, I did the function, it is returned what the exercise asks, but not step.
4
The return
is an instruction for the function, has no connection with the console.log
.
The console.log
is a method that was "idealized" a short time ago (when there was already javascript and browsers) to debug the scripts, you do not use it for "production" but rather for development.
The correct would be to "return" using return
and capture this return with console.log
The return
works like this
function test(){
return "test";
}
console.log(test());
So the code should be:
function nameString(name)
{
return "Oi, eu sou " + name;
}
console.log(nameString("Allan"));
console.log(nameString("Susie"));
console.log(nameString("Fred"));
Note that the code runs until before the return
, but what comes after is not executed:
function nameString(name)
{
alert(1);//Isto será executado
return "Oi, eu sou " + name;
alert(2);//Isto NÃO será executado
}
I’ve tried using Return, but this message appears: "Oops, try again. It seems that Voce did not show anything on the console! You remembered to use console.log() in the result of passing your name to the nameString function()?"
@The things you called it console.log(nameString("Allan"));
?
Friend, thank you very much. Just to be clear, it means that "Return" does not return by console ?
@Allansantos This the return
is an instruction for the function, has no connection with the console.log
, the console.log
is a method that was invented a short time ago (when there was already javascript) to debug scripts, you do not use it for "production" but rather for development :)
4
You gotta make two things right:
return
Code Academy is a Robot, you have to do as he wants.
#1 - Notice that your job should be return
instead of console.log
. What is intended is for the function to return and then do console.log
function invocation (of its return).
What is intended is return "Oi, eu sou" + " " + name;
and not console.log("Oi, eu sou" + " " + name);
Then you can do console.log(nameString('Sergio'));
or var return = nameString('Sergio'); console.log(return );`
#2 - Notice that oi
and Oi
sane strings different. you have to start with big letter.
The code as it should be:
var nameString = function (name) {
return "Oi, eu sou" + " " + name;
};
console.log(nameString('Sergio'));
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
Test write the
oi
large letter... ->Oi
. This Academy code is a rôbot...– Sergio