Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data And Hadoop Fundamentals Tools And Techniques For Data Driven Success

Authors: Mayank Bhushan

2nd Edition

9355516665, 978-9355516664

More Books

Students also viewed these Databases questions

Question

1. Is IPR a failure at North Trust?

Answered: 1 week ago