#i

33 messages · Page 1 of 1 (latest)

long thunder
#

can I see sister_golden_hair.txt?

long thunder
#

it looks like you have an issue handling the spacing with the [ and ] characters

#

try initializing chords with " " there is a space in here

#

remove the addition of a space under the if(line[j]=="]")

#

and put chords=chords.slice(0,chords.length-1) where the arrow is

#

it will remove the character preceding the [ which should be a space

#

any luck?

#

@lethal bronze

#

its under the if but before the for

#

are you allowed to use padding ?

#

it's a normal part of javascript part of the string class

#

but I dunno what kind of things you can use and not

#

the problem is that there is more text being added to chords than there is space to line it up

#

like say you have [Abcdefeg]hi [zxcvbvbxcb]bye [asdfsadfsdfs]go

#

without spacing out the high by go there is no way to space it out

#

sur

#

e

#

sure @lethal bronze

#

lol thats basically what you have already

#

@lethal bronze but you are missing the offset to handle the case that I was talking about

#
for (let line of array) {
        lyrics = ""
        chords = ""
        let defeceit = 0;

        for (i = 0; i < line.length; i++) {
            if (line[i] == "[") {
                let inner = ""
                for (j = i + 1; j < line.length; j++) {
                    if (line[j] == "]") {
                        break
                    }
                    inner += line[j]
                    i = j + 1
                }
                chords += inner+" ";
                defeceit += inner.length+1;
            }
            else {

                lyrics += line[i]
                if (defeceit == 0)
                    chords += " "
                else defeceit--;
            }
        }```
#

you can try that

#

but it basically does what the solution does

#

@lethal bronze

#

yeah of course

#

did you understand the problem that was occuring

#

@lethal bronze

#

well the inner part of the [ ] takes up some space so when you have a lot in there it will misalign the text by the number of additional characters that are inside of the [ ]

#

so what you can do is count the amount of additional characters that occur inside of the [ ] and instead of adding a space like normal when you are going through the lyrics you first enter nothing for the number of characters that were in there cause they are taking up space themself

#

[1234567]hello world will use up 7 spaces so for that sized tag you can skip putting spaces for the alignment cause the 7 will already put you over the W in world like

1234567
hello world```
#

@lethal bronze did that help?