Tell us what’s happening:
Hello. I created a code but there is an error in it. Please help me. The problem is: Sorry, your code does not pass. Don’t give up.
You should create a variable called calorieCounter. // running tests 1. You should create a variable called
calorieCounter
. 2. You should have
document.getElementById('calorie-counter')
in your code. 3. You should assign
document.getElementById('calorie-counter')
to your
calorieCounter
variable. // tests completed // console output [ReferenceError: calorieCounter is not defined] [ReferenceError: calorieCounter is not defined]
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calorie Counter</title>
</head>
<body>
<form id="calorie-form">
<label for="food">:</label>
<input type="text" id="food" name="food" required>
<label for="calories">Введите количество калорий:</label>
<input type="number" id="calories" name="calories" required>
<button type="submit"></button>
</form>
<script>
const calorieCounter = document.getElementById('calorie-form');
console.log(calorieCounter);
</script>
</body>
</html>
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 OPR/114.0.0.0
Challenge Information:
Learn Form Validation by Building a Calorie Counter - Step 14