I am working on a project and am encountering an obstacle on something rather small. I am trying to take an array that has a string and a nested array. Remove the string assigning it to a new variable and then destructure the nested array into two new variables. I seem to be having problems as there is an undefined placeholder and I can't seem to find a way to get around it. I think I must be messing something up simple, but I would appreciate it if you could help me understand my mistake. Any help would be great.
Here is the code which I can't seem to get working.
let operandArray = ['x', [1, 1]]
let temporaryArray = [];
const operator = operandArray.shift();
temporaryArray = operandArray[0];
console.log(temporaryArray);
let [operand1, operand2] = [...operandArray];
console.log(operandArray);
console.log(operand1, operand2)
.as-console-wrapper { max-height: 100% !important; }