+ 5
Hi Friends iam new to javascript Functions so plase help me to understand this code
function name(yourname){ x=10; var x; document.write(x); } document.write(name("imran")); its result 10 and undefined, when I remove this document.write() from name() its result 10, can I return yourname parameter or what I do, I have some problem with the return property.so please help me.
1 Resposta
+ 4
If you want to return any value from function then you can right like this.
function name(yourname) {
return yourname;
}
If you want both means print other value and return name then you can write like this
function name(yourname) {
var x = 10;
document.write(x);
return yourname;
}
It will print the value of x as well as returns name also.