1

I'm trying to run this code:

var elements_var = "Csus2 FM Dm CM";
var elements = ["Csus2","FM","Dm","CM"];

var note_var = (elements.join('\xa0'));

console.log("elements.join output:")
console.log(note_var);

console.log("Regular string output:")
console.log(elements_var);
note_2 = note_var;


const chordsClip = scribble.clip({
    // Use chord names directly in the notes array
    // M stands for Major, m stands for minor

    notes: note_var,
    pattern: 'x---'.repeat(4)
});

And this is the Console output:

Console Output

As you can see while console displays "Csus2 FM Dm Cm" correctly in both regular string (elements_var) and elements.join output (note_var), note_var seems to be missing it's first char when passing it to another function.

Function works perfectly when elements_var is inserted instead of note_var. What's happening? How can I fix this issue?

9
  • 2
    \xa0 is a non-breaking space, so your strings are not equivalent. Why not use a space instead? Commented Jan 30, 2020 at 18:12
  • 1
    The comment in your code seems to suggest that the notes property must be set to an array, not a string. Commented Jan 30, 2020 at 18:18
  • 1
    I think this is the scribbletune library. Can you confirm, OP? Commented Jan 30, 2020 at 18:20
  • I don't know I always used \xa0 so I'm used to it. Now I've used \u0020 and it worked. But still it's a question in my mind why does this happen when using \xa0 ? Commented Jan 30, 2020 at 18:22
  • 1
    @trincot If I've identified the right library, it can be either a string or an array of strings Commented Jan 30, 2020 at 18:22

1 Answer 1

1

Using \u0020 instead of \xa0 solved the problem.

But still don't know why this happen when using \u0020 cause it has nothing to do with the first char of the first element in the array.

Sign up to request clarification or add additional context in comments.

6 Comments

\u0020 is the space symbol.
No1 said it's not. Why it doesn't replace the first char of the first element in array but \xa0 does? the question was that.
Because the library expects spaces, not non-breaking spaces. Report it to them if you consider it a bug.
If you're wondering why you see sus2 instead of Csus2 is because the error thrown on line 47 is using the chordName which was set from line 24 which does not include the first character of the tokenized name. I'd spend more time tracing it through but without a running working example, that's all I could come up with.
@chazsolo I know why the error is thrown mate thanks. Does any1 besides Amy reads the things above? I'm curious about why \xa0 is removing first char.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.