var toon = element.getAttribute("data-toon"); if (!toon) return;
case "root62":
if (chord.includes(toon)) {
const index = chord.indexOf(toon);
chord.splice(index, 1);
} else if (!chord.includes(toon)) {
chord.push(toon);
}
break;
console.log(chord); ["C268"]
How do I remove the double quotes from C268?
Please note that we can only address JavaScript questions and issues in the context of Tumult Hype, so please attach a Hype document so others can dig into what you have so far.
Yes, this works for the console.log. Thank you.
I think I wasn't clear, but it needs to come instead of (toon).
Now it is: includes("C268")). It should be: includes(C268).
I refer to the attribute and it automatically puts double quotes around C268.
You should be more clear what you want todo… please share you're file. The code above makes no sense. Your switch statement code but the most is missing. Setting vars outside a case is also strange/unusual.
includes checks if a value is contained in an array:
String are always set in quotes in JavaScript because they can contain newlines and spaces. Only variable names and commands are without quotes. So, saying chords.includes(C268) is actually saying check if chords includes the content of the variable named C268. That is not what you want… you want to check for the string "C268".
consider taking the playbutton out of the function ... at least it's been unreachable ... with the toon-check ... just disabled the check ... you should consider this in setting up a new logic ...