I am a newbie JS developer and although the below code works perfectly fine with 2 variables and with IF statement but I want to know is there any elegant way of doing it WITHOUT IF statement.
The working code is below:
let animation;
if(!detectScroll && !detectHover){
animation = loadAnimation(reverseAnimationData)
}
else if(detectScroll && !detectHover){
animation = loadAnimation(cyanAnimationData)
}
else if(!detectScroll && detectHover){
animation = loadAnimation(cyanAnimationData)
}
else {
animation = loadAnimation(cyanAnimationData)
}
I want to know that can I reduce code into less lines of code with any other way without IF statement.
Aucun commentaire:
Enregistrer un commentaire