Syntax Error - Missing Parentheses - Control Flow/Iteration

I have two sets of code here that are getting the same error. When I run the code, there is an unexpected token/syntax error “)” but I don’t see where I’m missing a parentheses. Is my program glitching or does anyone else see my error?

— CODE 1 —
The instructions were to:
Iterate through the array and multiply a number by 10 if it is greater than or equal to 5.
const timesTenIfOverFive = [23, 9, 11, 2, 10, 6];

for (i = 0; i < timesTenIfOverFive; i++) {
  if (timesTenIfOverFive[i] >= 5 ===) {
      timesTenIfOverFive[i] *= 10;
    }
}

console.log(timesTenIfOverFive);

The instructions were to:
Iterate through the array and multiply a number by 10 if it is greater than or equal to 5.

The results should run: 230, 90, 110, 2, 100, 60

— CODE 2 —

instructions: You are provided with an object called checkObj . Using a for... in loop, determine if the object contains the property foundNum . If it exists, reassign the value of found to 1.

const myNums = [50, 75, 90]
  for (let i = 0; i < myNums.length; i++) {
    const num1 = myNums[i];
   for (let j = 0; j < myNums.length; i++) {
     const num2 = myNums[j];
     console.log('sum:', num1, num2);
   }    
  }

The issue is caused by this comparison operator that isn’t comparing anything


The second piece of code is an infinite loop, which is why it’ll be throwing an error. Notice how in the second for loop, you’re incrementing i, and not j?

 for (let j = 0; j < myNums.length; i++) {
                                    ^
2 Likes

You aren’t missing a ) but you have 2 comparison operators. One before and after the 5 and only comparing the 5 to 1 thing instead of 2.

1 Like