-1
How do I enter a number, how do I add it in the code (imc calculator in typescript)?. And how do I add it in the code if
s to inform healthy, obese, about weight, etc...
const calculadora = document.querySelector<HTMLFormElement>('#calculadora')!
const peso = document.querySelector<HTMLInputElement>('#peso')!
const altura = document.querySelector<HTMLInputElement>('#altura')!
const mensagem = document.querySelector<HTMLParagraphElement>('#mensagem')!
const retorno = document.querySelector<HTMLParagraphElement>('#retorno')!
function calculoIMC (peso: number, altura: number) {
return peso / (altura*altura)
}
calculadora.addEventListener('click', (e: Event ) => {
e.preventDefault()
let novoPeso = parseFloat(peso.value)
let novaAltura = parseFloat(altura.value)
mensagem.innerText = "Seu IMC e de :" + (calculoIMC (novoPeso, novaAltura))
})
Do not use images of your code, post it in the question. It is easier to help. See these tips for better guidance.
– Cmte Cardeal
const calculator = Document.querySelector<Htmlformelement>('#calculator')! const peso = Document.querySelector<Htmlinputelement>('#weight')! const height = Document.querySelector<Htmlinputelement>('#height')! const message = Document.querySelector<Htmlparagraphelement>('#message')! const return = Document.querySelector<Htmlparagraphelement>('#return')! Function calculoIMC (weight: number, height: number) { Return weight / (height*height) }
– Vitória Caroline
calculadora.addEventListener('click', (e: Event ) => {
 e.preventDefault()
 let novoPeso = parseFloat(peso.value)
 let novaAltura = parseFloat(altura.value)
 mensagem.innerText = "Seu IMC e de :" + (calculoIMC (novoPeso, novaAltura))
})
– Vitória Caroline
Okay, Victoria, I see you’re starting to use the site now. No problem I still don’t know how to post the code, but I made an edition of your question, and I highlighted your code. See how it was for you to base yourself in the future. It’s always good to post the code on yourself and not images of it, okay? D
– Cmte Cardeal
This answers your question? Round a number to Top 4023.8599999999997€
– Ricardo Pontual
has several questions/answers here on the site of how to round up using javascript
– Ricardo Pontual
Besides, the question isn’t about Typescript. Since rounding is done in Runtime (and not in Compile time), it’s about Javascript...
– Luiz Felipe