Can someone tell me what's wrong with this javascript? -
i trying experimental here, please answer, what's wrong in code?
function run(){ for(var i=0;i<arguments.length;i++){ var type=arguments[i].split(" ")[0]; if(type=="(write)"){ var arr=arguments[i].split(" "); var str=[]; for(var i=1;i<arr.length;i++){ str.push(arr[i]); } var fin="\n"+str.join(" "); document.getelementbyid("console").textcontent+=fin; } } } run( "(write) wonder if works.", "(write) think does!" );
somehow puts "i wonder if works." in div no "i think does!". can tell me what's wrong , return corrected script?
javascript not have block scope.. change other var else
Comments
Post a Comment