function solve(eq){
console.log(Array.isArray(eq));
let ops;
let op;
let calc;
while(eq.length>1){
ops = getOps(eq);
op = highestPriority(ops);
calc = calculate(eq[op[1]],eq[op[1]-1],eq[op[1]+1]);
eq = reduceExpr(eq,op[1],calc)
}
return eq;
The error is triggering on the line: while(eq.length>1){
I checked:
Array.isArray(eq) yields a true log, so it is not that eq does not have a length attribute.
I earlier also used console.log(eq.length) and got 3 (my expected output)
Also checked the element types : all are string type
I have read a few articles on debugging the TypeErrors but none of the solutions seemed relevant previously checked.
For the curious this is a part of a basic calculator exercise I am building.
Anyone have any ideas on what else I can check?
krward987 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2