I have created a script that removes part of a string if any of these characters are present:,
&
and /
I have created a function that returns the string with the portion of text I need.
But I want to join all conditionals in the function, since it is not good technique to have 3 IFs.
Example:
currentArtist = 'Dimitri Vegas & Like Mike,Paris Hilton/Dimitri Vegas'
Return: Dimitri Vegas
Example2:
currentArtist = 'Tiësto, Jonas Blue , Rita Ora'
Return: Tiësto
this.refreshLyric = function(currentArtist) {
if (currentArtist.includes("&")) {
let i = currentArtist.indexOf("&");
var currentArtist = cleanText(currentArtist, i);
}
if (currentArtist.includes("\/")) {
let i = currentArtist.indexOf("\/");
var currentArtist = cleanText(currentArtist, i);
}
if (currentArtist.includes(",")) {
let i = currentArtist.indexOf(",");
var currentArtist = cleanText(currentArtist, i);
}
}
function cleanText(artist, index){
let currentArtist = artist.substring(0,index);
return currentArtist.trim();
}