Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The snippets of JavaScript below contain syntax errors and/or logic errors. Iden

ID: 3927849 • Letter: T

Question

The snippets of JavaScript below contain syntax errors and/or logic errors. Identify the errors and insert your corrected code.

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();

f-

function main()

      {

          var total;    

                 var total = Number(prompt("Enter your total "));

                 if (total > 100)

      console.log("You have scored over 100% ");

                 end if

      }

    main();

Explanation / Answer

Quetion 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();

Question 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 >= 20000 && salary < 40000)

          {

                  console.log("You are in the middle salary range ");

          }

          else

          {

                  console.log("You are in the highest salary range ");

          }

    }

    main();

Question 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();

Question d:

function main()

      {

          var age;

          age = Number(prompt("Enter your age "));

          if (age > 20)

{

                  console.log("You are older than 20 years ");

          }

    }

    main();

Question f:

function main()

      {

          var total;    

                 var total = Number(prompt("Enter your total "));

                 if (total > 100) {

      console.log("You have scored over 100% ");

}

      }

    main();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote