I am in a intro to programming class where the assignments are in visual logic. This week's class is a assignment to gather food intake, calorie intake and a if statement which I was able to do in logic. Next class is webdesign so i thought why not try the same thing in javascript and get some experience with javascript but i'm running into problems. My user input for the calories is not converting to a integer for me to add the values together. Help please, I've read and researched and tried multiple things. Code is below
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Calorie Burner Program</title>
<script type="text/javascript">
</script>
</head>
<body>
<script type="text/javascript">
//I named my variables here
var TotalCal, Food1, Cal1, Food2, Cal2, Food3, Cal3, Food4, Cal4, Food5, Cal5, Food6, Cal6, Food7, Cal7, Food8, Cal8, Food9, Cal9, Food10, Cal10, Food11, Cal11, Food12, Cal12, Food13, Cal13, Food14, Cal14, Food15, Cal15, Food16, Cal16, Food17, Cal17, Food18, Cal18, Food19, Cal19, Food20, Cal20
//i'm prompting for the food
Food1 = window.prompt("What did you eat today?");
//Here i'm prompting for calories and I would like to reference the input above. as you can see from the code i've tried multiple suggestions
Cal1 = parseInt(prompt("How many calories was " + Food1, "0"), 10);
Food2 = window.prompt("What did you eat today?");
Cal2 = parseInt(prompt("How many calories was " + Food2, "0"), 10);
Food3 = window.prompt("What did you eat today?");
Cal3 = window.prompt("How many calories was" + " " + Food3);
....
Food20 = window.prompt("What did you eat today?");
Cal120 = window.prompt("How many calories was" + " " + Food20)
//you can see below that i've tried multiple methods and i get 5 everytime because my calories is 5 on every item i enter for testing
TotalCal = Cal1, + Cal2, + +Cal3, + +Cal4, + +Cal5, + +Cal6, + +Cal7, + +Cal8, + +Cal9, + +Cal10,+ +Cal11, + +Cal12, + +Cal13, + +Cal14, + +Cal15, + +Cal16, + +Cal17, + +Cal18, + +Cal19
alert("The number of calories you consumed today was " + TotalCal);
</script>
</body>
</html>