Learn Basic Algorithmic Thinking by Building a Number Sorter

can someone explane how foreach parameters work ,i mean if they are local variables they should still be assigned to a value
what i mean is how can foreach method know that num is number and i is the index

const updateUI = (array = []) => {
  array.forEach((num, i) => {
    const outputValueNode = document.getElementById(`output-value-${i}`);
    outputValueNode.innerText = num;
  })
}

because it was coded that way. And if you want to know what parameters a built-in function takes you can look at the documentation

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.