r/JavaScriptTips • • Apr 17 '23

Help

Post image

I’m working on a sample problem for ATA and I keep getting an “illegal parenthesized expression” error. Can someone tell me what I’m doing wrong and how can I fix it?

0 Upvotes

9 comments sorted by

4

u/Extension_Spirit8805 Apr 17 '23 edited Apr 17 '23

This post is cursed! this is absolutely not javascript, you're either using java or C#, seeing this looks like Eclipse, I'll assume the former.

First off, I am unsure on what you are reinitializing "weights" for, just use the array "weights" that you passed in the parameter. Also on line 18, you are trying to get each float number in the array, right? I think you'll need to do something like "weight = weights[i]".

If you can make clear to those 2 remarks, I think you'll be able to figure out the rest on how to make this function work the way you want it to!

2

u/[deleted] Apr 17 '23

I might be Java actually, I didn’t know there’s a difference between Java and JavaScript

2

u/Extension_Spirit8805 Apr 17 '23

Big difference! Here is an article giving a brief overview of the differences between the two. https://www.google.com/amp/s/www.geeksforgeeks.org/difference-between-java-and-javascript/amp/

It's important not to confuse between the two languages. Back in the day, java was the best for backend development, and javascript as frontend development (perhaps less true today, but still holds true in older versions).

The reason it has been named "JavaScript", is that it was created as a way of making a complimentary language to work with Java, interacting between web & servers smoothly.

Hope this helps!

1

u/Safe-Engineering69 Apr 17 '23

The error stack trace looks like Java code.

6

u/Safe-Engineering69 Apr 17 '23

This is Java code, not JavaScript?

1

u/[deleted] Apr 17 '23

Thank you all for the feedback

3

u/zediogox96 Apr 17 '23

Typo on the boolean variable, missing ‘l’

0

u/azronio Apr 17 '23

You don't initialize arrays like that in JS, use square brackets [0, 1, 2]. Curly braces to initialize an array is a different language syntax like C#.