Hi there
I just keep getting this outcome and I’m not sure what changes I need to make, or where
SyntaxError: unknown: Support for the experimental syntax ‘jsx’ isn’t currently enabled (24:3): 22 | const HTMLString =
23 | <label for="${entryDropdown.value}-${entryNumber}-name">Entry ${entryNumber} Name</label>
; > 24 | ; | ^ 25 | } 26 | yarn add @babel/preset-react --dev Add @babel/preset-react (babel/packages/babel-preset-react at main · babel/babel · GitHub) to the ‘presets’ section of your Babel config to enable transformation. If you want to leave it as-is, add @babel/plugin-syntax-jsx (babel/packages/babel-plugin-syntax-jsx at main · babel/babel · GitHub) to the ‘plugins’ section to enable parsing.
After your
label
element, and on a new line in your template string, create aninput
element. Give it atype
attribute set totext
, aplaceholder
attribute set toName
, and anid
attribute that matches thefor
attribute of yourlabel
element.
const calorieCounter = document.getElementById('calorie-counter');
const budgetNumberInput = document.getElementById('budget');
const entryDropdown = document.getElementById('entry-dropdown');
const addEntryButton = document.getElementById('add-entry');
const clearButton = document.getElementById('clear');
const output = document.getElementById('output');
let isError = false;
function cleanInputString(str) {
const regex = /[+-\s]/g;
return str.replace(regex, '');
}
function isInvalidInput(str) {
const regex = /\d+e\d+/i;
return str.match(regex);
}
function addEntry() {
const targetInputContainer = document.querySelector(`#${entryDropdown.value} .input-container`);
const entryNumber = targetInputContainer.querySelectorAll('input[type="text"]').length;
const HTMLString = `
<label for="${entryDropdown.value}-${entryNumber}-name">Entry ${entryNumber} Name</label>`;
<input type="text" id="${entryDropdown.value}-${entryNumber}-name" placeholder="Name" />;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Challenge Information:
Learn Form Validation by Building a Calorie Counter - Step 46