I have written this code in a widget and it works fine.
Did I forget something syntactically or why is the color coding in the css field so different?
Here I have the code
JS{{
var css = ''
var allKeyNames = ["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"]
var k = (VAR{keyNoteNumber} || 0) + 1
var scale = VAR{scaleJSON} || [0,2,4,5,7,9,11]
var l = scale.length-1
css += ".key:nth-child(" + (k) + ") inner {background-color: #cc0000}\n"
for( let i=1; i<=l; i++ ) {
var outside = (scale[i] + k)
if (outside > 12) {
outside = outside -12
}
css += '.key:nth-child(' + (outside) + ') inner {background-color: orange}\n'
}
css += ".key > inner { border: 1px solid #111}"
return css
}}
and here how the color coding looks in the css field.
Since I am not so good at coding, it confuses me when the colors are no longer correct. See example:
var k (is white)
var scale (is red)