Hey guys, i wanted to go further with the exercises lesson 11 and reminder everything i’ve seen so far.
On the last exercise, for the shopping trip, i am trying to make the list and the total price of shopping appear on a webpage.
Actually i can do it, my only problem is when using “\n” to go to the next line.
I am trying to have each product appearing on a separate line and i can’t do it, wherever i put this “\n” sign.
Is my way of coding correct?
Where do i put those “\n” in order to get what i want to? i am struggling since the beginning with those “\n” signs, probably i forgot something
`<html>
<head><h1>Shopping trip !</h1>
</head>
<body>
<script>
var bread = 2;
var milk = 1.5;
var cheese = 4;
var yogurt = 1.2;
var curr = "euro";
var nbread =prompt("How much bread?");
var nmilk =prompt("How many litters of milk");
var ncheese =prompt("how many pieces of cheese");
var nyogurt =prompt("how many cups of yogurt");
var pbread =bread*nbread;
var pmilk =milk*nmilk;
var pcheese =cheese*ncheese
var pyogurt =yogurt*nyogurt;
var total = pbread+pmilk+pcheese+pyogurt;
console.log(total+curr);
</script>
Number of bread :<script type="text/javascript">
document.write(nbread)
</script>
Litters of milk :<script type="text/javascript">
document.write(nmilk)
</script>
Pieces of cheese :<script type="text/javascript">
document.write(ncheese)
</script>
Cups of yogurt :<script type="text/javascript">
document.write(nyogurt)
</script>
TOTAL : <script type="text/javascript">
document.write(total+curr)
</script>
</body>
</html>`
Thank you !