Find the errors Javascript a function main var score score
Find the errors Javascript
a. function main() { var score; score = getScore(score); displayGrade(score); } function getScore (score) { score = Number(prompt(\"Enter your exam score\")); return score; } function displayGrade (score) { if (score < 70) { console.log(\"You have earned a satisfactory grade (C or better)\"); } else { console.log(\"You have earned an unsatisfactory grade (D or lower)”); } } main();
b. function main() { var salary; salary = Number(prompt(\"Enter your yearly salary \")); if (salary < 20000) { console.log(\"You are in the lowest salary range \"); } if (salary < 40000) { console.log(\"You are in the middle salary range \"); } else { console.log(\"You are in the highest salary range \"); } } main();
c. function main() { var course= prompt(\"Enter the name of your computer course \"); if (course = \"COMP-101 \") { console.log(\"That is a great course \"); } } main();
d. function main() { var age; age = Number(prompt(\"Enter your age \")); if age > 20 then { console.log(\"You are older than 20 years \"); } } main();
e. function main() { var total; var total = Number(prompt(\"Enter your total \")); if (total > 100) console.log(\"You have scored over 100% \"); end if } main();
Write the Algorithm, Pseudocode
A person’s body mass index (BMI) is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula:
 
                   BMI = Weight x 703 / Height 2
 
 In the formula, weight is measured in pounds and height is measured in inches. The program should display a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person’s weight is considered to be optimal if his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is considered to be underweight. If the BMI value is greater than 25, the person is considered to be overweight.
Solution
What are the changes required in javascript code i have made. check the following.
a)
function main()
 {
 var score;
 score = getScore(score);
 displayGrade(score);
 }
 function getScore (score) {
 score = Number(prompt(\"Enter your exam score\"));
 return score;
 }
 function displayGrade (score) {
 if (score > 70)
 {
 console.log(\"You have earned a satisfactory grade (C or better)\");
 }
 else {
 console.log(\"You have earned an unsatisfactory grade (D or lower)”);
 }
 }
 main();
 --------------------------------------------------------------------------------
  b)
 
 function main() {
 var salary;
 salary = Number(prompt(\"Enter your yearly salary \"));
 if (salary < 20000)
 {
 console.log(\"Your salary range is low \");
 }
 else if(salary >=20000 && salary < 40000)
 {
 console.log(\"Your salary range is medium \");
 }
 else {
 console.log(\"Your salary range is high\");
 }
 }
 main();
------------------------------------------------------------------------------------------------------------------
c)
function main() {
 var course= prompt(\"Enter the name of your computer course \");
 if (course = \"COMP-101 \")
 {
 console.log(\"That is a great course \");
 }
 }
 main();
 ----------------------------------------------------------------------------
  d)
function main() {
 var age;
 age = Number(prompt(\"Enter your age \"));
 if (age > 20){
 console.log(\"You are older than 20 years \");
 }
 }
 main();
 ------------------------------------------------------------------------------
  e)
 
 function main() {
 var total;
 var total = Number(prompt(\"Enter your total \"));
 if (total >= 100){
 console.log(\"You have scored over 100% \");
 }
 }
 main();
 ------------------------------------------------------------------------------------------------------------------------------------------------------------
Algorithm:
step1: Prompt User to enter body weight in pounds and height in inches
 step2: Read weight, height
 step3:calculate BMI
BMI=(weight*703)/(height*height);
 step4: if(BMI <=25 and BMI >=18.5){
 return \"Person Weight is optimal\"
 }
 else if(BMI>25){
 return \"Person Weight is Overweight \"
 }
 else{
 return \"Person Weight is Underweight\"
 }
 step5: exit;



