Inventory Update Challenge works in VS Code but not FCC?

Hi All,

Working on the Inventory Update challenge in the coding interview section. My code is working and returning the correct results in VS Code, but when I paste it into FCC and I get the error curInv is not defined.

curInv is defined where noted in line 3 of the code.

Does anyone know what’s going on?

TIA, Mark

'use strict'
function updateInventory(arr1, arr2) {
  let curInv = arr1                   // curInv is defined right here, not getting an error in VS Code
  let newInv = arr2
  let item
  
  let flatCurrent = curInv.reduce(    // flatten curInv for easier testing
    function(acc, curVal){
    return acc.concat(curVal)
  })
  
  for ( let i = 0; i < newInv.length; i++ ) {
    item = newInv[i][1]
    
    for ( let j = 0; j < curInv.length; j++) {    // if item is in current inventory, update count 
      if ( curInv[j][1] === item ) {
        curInv[j][0] = curInv[j][0] + newInv[i][0]
      }
    } 
  } // end for loop

  for ( let i = 0; i < newInv.length; i++ ) {  // push items not in current inventory
    item = newInv[i][1]
    if (!flatCurrent.includes(item)) {
      curInv.push(newInv[i])
    }
  }

  function compareSecondColumn(a, b) {  return (a[1] > b[1]) }  // sort and be done
  curInv.sort(compareSecondColumn) 
  console.table(curInv)

  return curInv;
} // end function

updateInventory(curInv, newInv);`

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/algorithms/inventory-update

Remove this call to the function in your code, because curInv and newInv are not defined outside the updateInventory function. You will still not pass all the tests, but you will not get the error you were receiving

FYI - If you run the exact same code above in VS Code, you will get the same error.

Thank you. I scrutinized every line of the function, but not didn’t think to look at the call itself.