How to remove quotes


I have this:

   	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)) {

console.log(chord);  ["C268"]

How do I remove the double quotes from C268?

:rotating_light: 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.

c268 can only be a string

Thank you. That's a pity. I need that without quotes.
I will have to find another way then.

It seems like you could just console.log("[" + chord.join(",") + "]")

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".

This is what I have. The hype file explains what is/should be happening. (139.3 KB)

Without digging to deep into your code ( for the mo).

You can convert a string into a var name normally like this.



tried to keep your logic ...

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 ... (146.7 KB)


You can store stuff in an object like window and reference it through a variable like toon using the following syntax: window[toon].play()

testChord.hype (161,6 KB)

PS: I personally wouldn't use window but rather hypeDocument or hypeDocument.customData


Wow! This is a nice reply @MarkHunte, @MaxZieb, @h_classen. Thank you.
Some study to understand what you've done. Once I get it, I'll let you know.

Your solution is the most convenient for me. I understand it and will use it. Thank you.

Not a competition for a solution but a rather a journey to understanding :slight_smile: