Build a Recipe Ingredient Converter - Step 18

Tell us what’s happening:

i need help here, i got stuck about this last step,
i donno how to solve it really
i tried to observe the others’s issues and the replies to get any hint

  • i got an error in the console it says type error can’t read properties of undefined when i try press the convert button

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) {
    let listItem = document.createElement('li')
    let convertedFunc = processIngredient(unitToConvert.value)(unit)(Number(ingredientQuantity.value))
    listItem.textContent = `${ingredientName.value}: ${convertedFunc.toFixed(2)} ${unit}`
      resultList.appendChild(listItem)
    // listItem.textContent += text
    }
  })
}


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

Challenge Information:

Build a Recipe Ingredient Converter - Step 18

How many arguments does processIngredient() take?

i think it should be four

Yes. Also, is processIngredients a curried function?

1 Like

No, it’s not :slight_smile:
what a disaster i commited in my code :blush:

i wasn’t know i can pass it, you pushed me up, yes you did it .
many thanks master dhess

The issue is that `processIngredient` is a **curried function**, not a regular one.

That means it doesn’t take all arguments at once. Each call returns another function until all arguments are provided.

Instead of calling it like this:

processIngredient(unitToConvert.value)(unit)(Number(ingredientQuantity.value))

You need to pass the arguments in the correct order, step by step.

Example fix:

let convertedFunc =

processIngredient(ingredientName.value)

(unitToConvert.value)

(unit)

(Number(ingredientQuantity.value));

The error happens because `.toFixed()` is being called on `undefined` when one of the function calls is missing.

After passing all arguments correctly, the Convert button should work.

1 Like

processIngredient is NOT a curried function.

Thanks for the clarification, dhess! That makes sense now — I’ll update my code to pass all arguments at once. Appreciate the help! :folded_hands:

thanks very much for your help :slight_smile:

1 Like