Build a Recipe Ingredient Converter - Step 17

Tell us what’s happening:

I’m getting the correct output but I’m not passing step 17. What am I missing?

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

const updateResultsList = () => {
  resultList.innerHTML = "";
  units.forEach((unit) => {
    if (unit !== unitToConvert.value) {
      const convertedValue = convertQuantity(unitToConvert.value)(unit)(ingredientQuantity.value);
      const item = document.createElement("li");
      item.textContent = `${ingredientName.value}: ${convertedValue.toFixed(2)} ${unit}`;
      resultList.appendChild(item);
    }
  })
}
document.querySelector("button[type='submit']").addEventListener("click", updateResultsList);


// 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/138.0.0.0 Safari/537.36

Challenge Information:

Build a Recipe Ingredient Converter - Step 17

You are using the wrong function.

I’ve changed the function but it’s still not passing

const updateResultsList = (event) => {
event.preventDefault();
resultList.innerHTML = “”;
units.forEach((unit) => {
if (unit !== unitToConvert.value) {
const convertedValue = processIngredient(parseFloat(ingredientQuantity.value), unitToConvert.value, unit, parseFloat(numberOfServings.value))
const item = document.createElement(“li”);
item.textContent = ${ingredientName.value}: ${convertedValue} ${unit};
resultList.appendChild(item);
}
})
}
recipeForm.addEventListener(“submit”, updateResultsList);

You have changed the given code in this step (this is not an event listener!). Please reset this step and paste your unit code back in to try again.

1 Like