Created
August 31, 2018 22:05
-
-
Save juanbrusco/f8a4d862ce4483faad2796aa84b493c1 to your computer and use it in GitHub Desktop.
Add item to array (if exists then remove) - Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.array = []; | |
selectCarouselItem(itemToAdd) { | |
if (this.array.indexOf(itemToAdd) != -1) { | |
this.array.splice(this.array.indexOf(itemToAdd), 1) | |
} else { | |
this.array.push(itemToAdd); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment