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

142
Views
Preguntar por interruptor/caja
let rachunek = prompt('Podaj cene rachunku'); switch(rachunek) { case rachunek >=50 && rachunek <= 300: console.log('Cena rachunku wynosi ' + rachunek + ' zł ' + 'natomiast napiwek wynosi' + rachunek * 0,15 + ' zł'); break; case rachunek < 50 && rachunek > 300: console.log('Cena rachunku wynosi ' + rachunek + ' zł ' +'natomiast napiwek wynosi' + rachunek * 0,2 + ' zł'); break; default: console.log('Złe dane'); }

No sé qué pasa, porque la terminal siempre me muestra solo 2 zł de propina.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

 let rachunek = prompt('Podaj cene rachunku'); switch(true) { case rachunek.length >=50 && rachunek.length <= 300: console.log('Cena rachunku wynosi ' + rachunek + ' zł ' + 'natomiast napiwek wynosi' + rachunek * 0,15 + ' zł'); break; case rachunek.length < 50 && rachunek.length > 300: console.log('Cena rachunku wynosi ' + rachunek + ' zł ' +'natomiast napiwek wynosi' + rachunek * 0,2 + ' zł'); break; default: console.log('Złe dane'); }

Su expresión de cambio debe ser un evento verdadero, verifique su cadena de longitud, por favor

 let rachunek = prompt('Podaj cene rachunku'); switch(true) { case rachunek.length >=50 && rachunek.length <= 300: console.log('Cena rachunku wynosi ' + rachunek + ' zł ' + 'natomiast napiwek wynosi' + rachunek * 0,15 + ' zł'); break; case rachunek.length < 50 && rachunek.length > 300: console.log('Cena rachunku wynosi ' + rachunek + ' zł ' +'natomiast napiwek wynosi' + rachunek * 0,2 + ' zł'); break; default: console.log('Złe dane'); }
over 4 years ago · Santiago Trujillo Report

0

Switch no calcula, solo compara. if se debe usar para calcular.

 let rachunek = prompt('Podaj cene rachunku'); if( parseInt(rachunek) >=50 && parseInt(rachunek) <= 300){ console.log('Cena rachunku wynosi ' + rachunek + ' zł ' + 'natomiast napiwek wynosi' + rachunek * 0,15 + ' zł'); } else if (parseInt(rachunek) < 50 && parseInt(rachunek) > 300){ console.log('Cena rachunku wynosi ' + rachunek + ' zł ' +'natomiast napiwek wynosi' + rachunek * 0,2 + ' zł'); } else { console.log('Złe dane'); }

Aquí está el uso lógico del interruptor.

 let result = "0" if( parseInt(rachunek) >=50 && parseInt(rachunek) <= 300){ result = "between50and300"; } else if (parseInt(rachunek) < 50 && parseInt(rachunek) > 300){ result = "notbetween50and300"; } else { result = "default"; }
 switch(result) { case "between50and300": console.log('Cena rachunku wynosi ' + rachunek + ' zł ' + 'natomiast napiwek wynosi' + rachunek * 0,15 + ' zł'); break; case "notbetween50and300": console.log('Cena rachunku wynosi ' + rachunek + ' zł ' +'natomiast napiwek wynosi' + rachunek * 0,2 + ' zł'); break; default: console.log('Złe dane'); }
over 4 years ago · Santiago Trujillo 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!