Skip to content
Advertisement

I cant look for a value in a object array, it returns me error [closed]

Hello everyone I’m doing this music player and this is the song loader but the problem is that when I try to assing the value to song constant with lookSongbyId function it returns me an error idk why

JavaScript

song constant is undefined, and I dont know why aghhh If u could help me with this code I’ve been so thankful with u :DDD

Advertisement

Answer

Assuming the functionlookSongbyId is just misspelled (you must write function lookSongbyId), the forEach function cannot be used to return a value, as indirectly said here. Use a for ... of or .find() to retrieve the element

Advertisement