-1
Hello I’m a beginner so I don’t know much about it but I was practicing and I realized that I couldn’t put line breaks in Document.write, so I decided to do it this way but I feel like I did it wrong. How could it diminish?
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Formulário de compra</title>
<style>
body{
background-color:wheat ;
color:black ;
font:oblique 22pt roboto;
}
h1{
color:black;
font:normal calibri;
}
</style>
</head>
<body>
<h1>Valor da Compra</h1>
<p>
<script>
var n1= Number(prompt('Quantos fardos de refrigerante de 2 litros?'))
var n2= Number(prompt('Quantos kilos de carne?'))
var n3= Number(prompt('Quantas sacolas de pão?'))
var jun1= n1*12
var jun2= n2*10
var jun3= n3*3.5
var tot= jun1+jun2+jun3
var res1=document.write('Preço do refrigerante:'+ jun1.toLocaleString('pt-br', {style:'currency', currency: 'BRL'}))
</script>
</p>
<p>
<script>
var res2=document.write('Preço da carne:'+jun2.toLocaleString('pt-br', {style:'currency', currency: 'BRL'}))
</script>
</p>
<p>
<script>
var res3=document.write('Preço do pão:'+jun3.toLocaleString('pt-br', {style:'currency', currency: 'BRL'}))
</script>
</p>
<p>
<script>
var res4=document.write('Preço da comida:' + tot.toLocaleString('pt-br', {style:'currency', currency: 'BRL'}))
</script>
</p>
</body>
</html>
Thank you very much, I do not know much about javascript yet but I will try to learn everything what you reported.
– Mundo Gamer