Normies gtfo, only real programmers ITT

Normies gtfo, only real programmers ITT.
So I started learning JavaScript and trying to submit my first challenge to leetcode but I can't because some wired runtime error.
The solution runs perfectly in node.
Whoever find whats wrong gets a cookie.
Pic releated. Here's the code:

function twoSum(nums, target) {

for(var i=0; i

Attached: chrome_wWp2VX6ihx.png (1920x979, 88K)

Other urls found in this thread:

Jow
twitter.com/NSFWRedditGif

You're supposed to return an array, not a string. Use code tags.

> real programmers plz
>JavaScript

Learn to use code tags.
I find it to be bad form to put a template literal in a return.
Clean up your syntax and problems might be more obvious. One of my first steps is always adding parenthesis to compound statements/expressions, or breaking up those into multiple lines.

Also, if you want to be a better programmer, consider finding ways to write code that more idiomatically describes the problem it's solving. I don't understand the point of this function. It finds two numbers from an array that add up to a given sun? Is there a more concise way to write this? Can you make it less confusing without losing performance? Could you have added a comment that makes it obvious what's happening and why you chose this design?

Attached: 1559853451337.png (958x718, 974K)

>only real programmers ITT.
>trying to submit my first challenge to leetcode but I can't

>only real programmers
>JavaScript
Lmao what a fucking retarded nigger. Kill yourself faggot

>normies

You forgot to account for duplicates as well. Also you’re trying to return a tuple or something, just append the two results to an arraylist and return that.

Spot on.

>I find it to be bad form to put a template literal in a return.
Why?
>It finds two numbers from an array that add up to a given sun?
yes

>Is there a more concise way to write this? Can you make it less confusing without losing performance?
>Could you have added a comment that makes it obvious what's happening and why you chose this design?
Probably but I'm a total noob and just wanted to see if i'll be able to solve it with the first thing that comes to mind

Why do everyone hates JavaScript so much? I've only dedicated a few days of work. Should I switch to Python? My long term plan is getting a dev job without getting a degree

"You may assume that each input would have exactly one solution, and you may not use the same element twice."
I did account for duplicates with i!==ii in the if statment

Attached: 1541093106083.jpg (800x1200, 150K)

>only real programmers ITT
>I started learning JavaScript
Why don't you GTFO of your own thread OP?

> Why?
It's just one of those things I usually see associated with bad code. I guess it's not necessarily a technical thing, but in my experience either the string should be created before the return, or the return should give the values and another function should be concerned with formatting the data into a string. It's usually a sign that a function is doing more than it should, unless the explicit purpose of the function was to return a string.