Question
There are five errors in the code below. List five of them and: identify the line by number, state if the error is an interpreter
There are five errors in the code below. List five of them and: identify the line by number, state if the error is an interpreter (syntax) error or a runtime (logic) error, and give a corrected version of the entire line.
1 var text = prompt('Enter a sentence'); 2 var letter = prompt('Enter a letter to count'); 3 var num = countLetters(text, letter);
4 5 document.writeIn('Found ' + num + ' ' + letter + 's');
.6
7 Function countLetters(alpha, phrase) 8 { var cnt = 0; 9 var i = 0;
10 11 while(i<=phrase.length) 12 { if(alpha == phrase[i]); 13 cnt++; 14 i++; 15 } 16 return cnt; 17 }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started