Skip to content

IMP: In Spotify clone #video-84 in finding index from array problem #194

@LomashB

Description

@LomashB

in new version of node or maybe in all(because i encountered it) we can not find index with the code you wrote which is this:

let index = songs.indexOf(currentSong.src.split("/").slice(-1)[0])
if ((index + 1) < songs.length) {
playMusic(songs[index + 1])
}

instead of that i suggest this for efficient and good finding because it always returns -1

suggested:

let songname = currentSong.src
.split("/")
.slice(-1)[0]
.replaceAll("%20", " ");
let index = songs.indexOf(songname);
console.log(songs, index, songname, songs.length);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions