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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!