79677790

Date: 2025-06-24 14:55:46
Score: 1
Natty:
Report link

First of all, you do not need 2 script for 2 different scenarios.

You've mentioned that you've used C++ and Java but the errors were simple and easy to solve.

You've used wrongly myAge variable and did not use the same in 2 different if condition.

I would suggest please use codepen and work on different javascript tutorials.

Thank you.

var yourName = prompt("What is your name?");
var myAge = prompt("What is your age");

if (yourName != null) {
  document.getElementById("sayHello").innerHTML = "Hello " + yourName;
} else {
  alert("Please enter your name correctly");
}


if (myAge < 4) {
  document.write("You should be in preschool");
  }
  else if (myAge > 4 && myAge < 18) {
    document.write("You should be in public private school");
  } else if (myAge > 18 && myAge < 24) {
    document.write("You should be in college");
  } else {
    document.write("you're in the work force now");
  }
body {
  font-size: 1.6em;
}

.hidden {
  display: none;
}

.show {
  display: inline !important;
}

button {
  border: 2px solid black;
  background: #E5E4E2;
  font-size: .5em;
  font-weight: bold;
  color: black;
  padding: .8em 2em;
  margin-top: .4em;
}
<p id="sayHello"></p>

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (1): What is your
  • RegEx Blacklisted phrase (1): I would suggest please
  • Long answer (-1):
  • Has code block (-0.5):
Posted by: Naeem Akhtar