What is the error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
23rd Jul 2017, 9:22 AM
Prabhakar Dev
Prabhakar Dev - avatar
14 Answers
+ 4
What do you really want this code to do.
23rd Jul 2017, 11:24 AM
RZK 022
RZK 022 - avatar
+ 2
Maybe .
23rd Jul 2017, 10:09 AM
RZK 022
RZK 022 - avatar
+ 2
You have two main mistakes, and a messy code (need to reorder instructions): + you write 'ouput' instead of 'output' in the id attribute of your html <div> + your 'for' loop is wrong, so the function never end (index error break execution), by testing if 'x' is less or equal to array length (need to be strictly less)... Fixed code: https://code.sololearn.com/Wj0gAXH431Xz/?ref=app
24th Jul 2017, 8:11 AM
visph
visph - avatar
+ 1
the syntax missed ; and the varibels on line 16 its out of the local scope of the first function. so you need cut and paste the varibele in local scop this issuse your problem .
23rd Jul 2017, 9:39 AM
Shabi Levi
Shabi Levi - avatar
23rd Jul 2017, 9:59 AM
RZK 022
RZK 022 - avatar
+ 1
I added one line . You didn't wrote that .
23rd Jul 2017, 10:04 AM
RZK 022
RZK 022 - avatar
+ 1
Compare it that's not the same .
23rd Jul 2017, 10:07 AM
RZK 022
RZK 022 - avatar
0
window.onload=function(){ var code,output,n=0; function chr(m){ return String.fromCharCode(97 + m);} function compile(){ for(var x=0;x<=code.length;x++){ if(code[x]=="+"){ ++n; } else if(code[x]=="-"){ --n; } else{ n=chr(n); } } output.innerHTML=n; code=document.getElementById("code").value; output=document.getElementById("output"); compile(); } } you need learn global and local scope with function. now its work.
23rd Jul 2017, 9:33 AM
Shabi Levi
Shabi Levi - avatar
0
Errors inform us of a messaging, which is something wrong.
23rd Jul 2017, 9:35 AM
Tanmoy Sau
Tanmoy Sau - avatar
0
hhh ok you are corrected it :) not me
23rd Jul 2017, 10:03 AM
Shabi Levi
Shabi Levi - avatar
0
look at first comment bro
23rd Jul 2017, 10:06 AM
Shabi Levi
Shabi Levi - avatar
0
ok but for this error its same same :)
23rd Jul 2017, 10:08 AM
Shabi Levi
Shabi Levi - avatar
0
@atikrant the code still doesn't didn't compile
23rd Jul 2017, 11:22 AM
Prabhakar Dev
Prabhakar Dev - avatar
0
the function is inside the name itself
23rd Jul 2017, 3:22 PM
Prabhakar Dev
Prabhakar Dev - avatar