Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
Number prediction from 1 to 10 from javascript

This is my code but when i run this code in console always giving me Congratulations. Help me for solve this problem.

var val=Math.floor(Math.random() * 10) + 1;
console.log(val);
var Predict = Number(prompt("Prediction ?"));

for(var i=1 ; i <= 3; i++){
  if(Predict<val){console.log("Up")};
  if(Predict=val){console.log("Congratulations") };
  if(Predict>val){console.log("Down")}
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Equal operator assigns the right hand to the left hand and so the result is always true! To compare two values use double equals like this:

if (Predict==val){console.log("Congratulations") };
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!