Interview Bootcamp
Ask Author
Back to course home

0% completed

Vote For New Content
Seemingly pointless declaration in JS solution

traviswlilleberg

Oct 22, 2025

Maybe I'm missing something but I don't see any reason to declare and use the s2 variable in the JS solution:

       let s2 = s1;               // Copy the dequeued binary number.
        queue.enqueue(s1 + "0");   // Enqueue the first generated binary number by adding "0".
        queue.enqueue(s2 + "1");   // Enqueue the second generated binary number by adding "1".

can be:

        queue.enqueue(s1 + "0");   // Enqueue the first generated binary number by adding "0".
        queue.enqueue(s1 + "1");   // Enqueue the second generated binary number by adding "1".

0

0

Comments
Comments