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

97
Views
juego de batalla naval / evita escribir lo mismo dos veces

tal problema es que si ingreso el mismo número 3 veces y me cuenta como una ganancia, pero necesito prohibirlo para que no pueda ingresar el mismo número una segunda vez, ¿pueden decirme cómo hacer esto?

 let randomLocation = Math.floor(Math.random() * 6) let location1 = randomLocation let location2 = location1 + 1 let location3 = location2 + 1 let guess let hits = 0 let guesses = 0 let isSunk = false while (isSunk == false) { guess = prompt('Enter the coordonation: ') let secondTime = guess if (guess < 0 || guess > 6) { alert('Your number is incorrect') } else { guesses++ if (guess == location1 || guess == location2 || guess == location3) { alert('SHOT') hits++ if (hits == 3) { isSunk = true alert('The ship was wrecked') } } else { alert('you missed') } } } let stats = 'You wrecked from ' + guesses + ' attempts ' + ' which means you have statistics ' + (3 / guesses) console.log(stats)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Aquí hay una forma de verificar si el usuario ha ingresado lo mismo antes. Usa un Set .

 let answers = new Set(); while(true) { let input = prompt('Enter something') if (input == null) break; if (answers.has(input)) { alert('You already entered that.'); } else { alert('That is new!') answers.add(input); // Remember this input for later. } }

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!