DNA Pairing challenge - TypeError: unknown: o is undefined - help needed

Hi guys, starting with JS and trying to really do everything on my own, hence the garbage code. It works in Visual Studio Code as intended, but FCC is throwing “TypeError: unknown: o is undefined” and for the love of God I can not figure out why. I thought I am missing { somewhere, but that does not seem to be the case. Any help is much appreciated!

`function pairElement(str) {
    var arr = [];
    while (arr.push([]) < str.length);
    var arr2 = str.split("");
    for (let i = 0; i < arr2.length; i++) {
        arr[i].splice(i, 0, arr2[i]);
    }
    for (let j = 0; j < arr.length; j++) {
        if (arr[j] == "G") {
            arr[j].push("C");
        } else if (arr[j] == "C") {
            arr[j].push("G");
        } else if (arr[j] == "T") {
            arr[j].push("A");
        } else if (arr[j] == "A") {
            arr[j].push("T");
        }
    }

    return arr;
}

console.log(pairElement("GCTAG"));`

It’s that line, it should be while (arr.push([]) < str.length) {}.
That passes the test for me!

Thank you so much! so I was indeed missing {} :smiley:

1 Like