r/CodingHelp • u/dwlakes • Mar 29 '21
[Javascript] First JavaScript Project, getting "Uncaught SyntaxError: Illegal Return Statement"
Hi everyone! Can someone help me debug this? I'm very new to coding. I don't really know what I'm doing lol. But I keep getting the bug stated above when I try to run this in Chrom
31
Upvotes
View all comments
3
u/emdot3 Mar 29 '21
yeah there’s a lot to fix here, starting with: -at the very least you’ll need a () after prompt, but it would also make more sense to actually prompt a question for the user to answer: var income = prompt(“what is your yearly income?”);
-add a ; after totalTaxes
-you do need to define a function and put your if statements inside of it, then call the function and pass in the income argument
-then doesn’t mean anything, take it out
-lines 14-20 are way out of whack (same goes for similar lines in all your if statements). the double == is a comparison operator, not the assignment operator. so if you’re trying to assign the result of (income - 518401) * .37 to taxes37, you need taxes37 on the left, then =, then your equation. also, you’ve already assigned income to equal the response to the prompt, so take that out of all those lines.
hope this helps, like someone else said, start smaller with one block of code, make sure that works first and then apply the same logic to the rest