0
Why function "return UNDEFINED" ?
var str = prompt(); var arr = str.split(''); var num = arr.length; for (var k=0;k<=num;k++) { var x = arr[k]; document.write(getString(x)); } function getString(x){ var div = document.createElement("div"); div.className = "className"; var oText = document.createTextNode(x); div.appendChild(oText); document.body.appendChild(div); }
2 Antworten
+ 2
// Because "x" is a variable parameter and he must need a "return" keyword to show the value of this variable, otherwise, he doesn't work.
+ 1
Because you haven't defined a return value at the end of your function.