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.

I meant duplicate values, say you had two sevens in there and a 14 was the target. I don’t think your code would push out 7, 7 as an answer. Could be wrong, I haven’t done Two Sum for months but I recall that being an issue for me.

With no degree and only knowing python or js, you'll be competing with pajeets and making similar money to if you just went and waited tables. If it fits into a longer path then go for it, but don't expect to make big bucks with that background and skillset. JavaScript and python are two languages that non-programmers learn all the time on the job. If you're picking these languages because they seem approachable, consider that any work that you can do with them that pulls in good money will be much more difficult than basic frontend web stuff or basic scripting. For example, some decent python jobs I've seen were projects that used python to script embedded controllers or interpret their data, which is not nearly as simple as doing some easy math or string manipulation. JavaScript is kind of a lang you'll probably end up wanting to know no matter what, but for really technical stuff, compiling other langs to webassembly will replace JavaScript, JavaScript will go back to simple interactivity, and possibly work as "glue" code.

>Normies
you need to go back

I'd answer, but you're clearly a normie so you don't belong in this thread.

>Normies gtfo
>So I started learning JavaScript

Attached: 1554658048279.jpg (317x330, 13K)

Also I forgot to ask. What do you mean by code tags? Like the tags you put in a html file? Why should I do that if I have a dediated js file?

Yeah, i've noticed that it's common practice to not take the shorteset way in order to maintain code readability

op doesn't have to follow the rules

I don't mind making a low wage for a year or two before getting a normal dev salary. Sounds much better than waisting years in university

I've already got enough answers but thanks

Attached: 1525305306522.jpg (667x593, 242K)

I've compared the indexes in the array and not the values themselves so that shouldn't be a problem.
See pic related

Attached: chrome_0RyBVj96xq.png (1920x979, 77K)

Ohh nice, I’ve been using Python a lot recently so it jumbled my syntax up.

>return (`[${i},${ii}]`)

Attached: 1534577564890.png (267x194, 22K)

Code tags for Jow Forums so the code you post doesn't look like shit, like this:
Console.log('nigger');

>What do you mean by code tags? Like the tags you put in a html file? Why should I do that if I have a dediated js file?
jesus fucking christ

>normie

kill yourself normalfag

test test 123

Jow Forums.org/rules#g

>What do you mean by code tags? Like the tags you put in a html file? Why should I do that if I have a dediated js file?
Major newfag alert.

I've acually been here for a while, I know all about sex robots and shit, just new to coding

Attached: When u free2many slaves.jpg (1347x1957, 1.79M)

this is the biggest bait in the world or OP is a moron

either way, big laugh

Attached: 1439481483043.jpg (220x236, 9K)

I'm glad this meme is still alive.

Sounds like you've been born a good developer

Attached: 7TfkS25.webm (636x358, 2.04M)