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

151
Views
get the largest number without an array

Im trying to get the largest number among the numbers the user give me without using a array, this is how i have done it:

let largestNum = 0
let userNum = 0
for(let i = 1; i<=3 ;i++){
    userNum = prompt("Give a number")
    if(userNum > largestNum){
        largestNum = userNum
    }
}document.write("the biggest number is: "+ largestNum)

Now, if im playing the user and insert first 10 and then 2 and 2, it print me that the largest number is 2! how come is it 2?! after the first time the largest number should turn into 10, and from then, no number is larger than 10! so how come it i gives me 2?

about 4 years ago · Juan Pablo Isaza
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!