SyntaxError: missing ) after condition

๋ฉ”์‹œ์ง€

SyntaxError: missing ) after condition

์—๋Ÿฌ ์œ ํ˜•

SyntaxError

๋ฌด์—‡์ด ์ž˜๋ชป ๋œ ๊ฑธ๊นŒ?

if์กฐ๊ฑด๋ฌธ์— ์—๋Ÿฌ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์–ด๋– ํ•œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ๋“  ์ฝ”๋“œ๋Š” ์ž…๋ ฅ๊ฐ’์— ๋”ฐ๋ผ ์˜์‚ฌ๋ฅผ ๊ฒฐ์ •ํ•˜๊ณ  ํ–‰๋™์„ ์ˆ˜ํ–‰ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. ์ง€์ •๋œ ์กฐ๊ฑด์ด true์ด๋ฉด if ๋ฌธ์ด ๋ช…๋ น๋ฌธ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์—์„œ๋Š” ์ด ์กฐ๊ฑด์ด if๋ฌธ ๋‹ค์Œ์˜ ๊ด„ํ˜ธ์— ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ์€ ๊ทธ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค.

if (condition) {
  // do something if the condition is true
}

์˜ˆ์‹œ

์‹ค์ˆ˜๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ์œผ๋‹ˆ, ๋ชจ๋“  ๊ด„ํ˜ธ๋ฅผ ์ฃผ์˜๊นŠ๊ฒŒ ํ™•์ธํ•˜์„ธ์š”.

if (3 > Math.PI {
  console.log("wait what?");
}

// SyntaxError: missing ) after condition

์ด ์ฝ”๋“œ๋ฅผ ๊ณ ์น˜๊ธฐ ์œ„ํ•ด์„ , ์กฐ๊ฑด๋ฌธ์„ ๊ด„ํ˜ธ๋กœ ๋‹ซ์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.

if (3 > Math.PI) {
  console.log("wait what?");
}

๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ฅผ ๋ฐฐ์šด ๊ฒฝ์šฐ, ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์—์„œ๋Š” ๋‹ค๋ฅด๊ฒŒ ์“ฐ์ด๊ฑฐ๋‚˜, ์“ฐ์ด์ง€ ์•Š๋Š” ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์‰ฝ์Šต๋‹ˆ๋‹ค.

if (done is true) {
 console.log("we are done!");
}

// SyntaxError: missing ) after condition

์ด ๊ฒฝ์šฐ ์˜ฌ๋ฐ”๋ฅธ ๋น„๊ต์—ฐ์‚ฐ์ž๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ ์˜ˆ์‹œ๋กœ:

if (done === true) {
 console.log("we are done!");
}

๋” ๋ณด๊ธฐ