#Mobile Ordering App

21 messages · Page 1 of 1 (latest)

minor blaze
#

The problem I am running into is that I cannot grab the single item object when clicking on the add item button. I have connected the add button via dataset and created a separate function where I filter over my data and save the new object then I am just logging it to the console, but it keeps giving me undefined.

tiny oar
#

Is the itemId what you expect?

minor blaze
tiny oar
#

ok, so does your console.log(orderedItemObj) give you what you expect?

minor blaze
#

It gives me undefined

tiny oar
#

ok then your menuArray doesn't contain the item you're looking for... can you cosole.log(menuArray) to see if the itemId exists in there?

minor blaze
#

Ok i just did and it does exist

tiny oar
#

take out the array reference and log orderedItemObj (without the [0]) to see if the filtered list contains the item)

#

wait

#

is the itemId a string?

#

console.log(typeof itemId)

#

I'll be it is... and I'll also be item.id is a number...

#

in JS "3" does NOT === 3

#

but "3" DOES == 3

minor blaze
#

Thats it

#

it was looking for a string

#

when my id was number

tiny oar
#

so you probably need to change return item.id === itemId to return item.id == itemId

minor blaze
#

thank you

tiny oar
#

np

minor blaze
#

I was starting to lose my mind lol