function sum(n){for(var i = 1;i>= 5;i++ ){ let n=0; n+=i;}} console.log(sum()) //where is the mistake .why does it not work? //t | SoloLearn: Learn to code for FREE!

+3

# function sum(n){for(var i = 1;i>= 5;i++ ){ let n=0; n+=i;}} console.log(sum()) //where is the mistake .why does it not work? //t

Tell where the mistake is please

3/3/2021 1:17:12 PM

Global Universe

+15

i<=5 ๐ป

+7

There is no "return" in your function

+5

https://code.sololearn.com/WyOEDiuAawbU/?ref=app

+2

Ouch.. sorry about that. Just i was hurried and named it with the first thing i thought about๐ณ๐ณ

+2

Patel Ashish we solve it already๐

+1

*to have๐

+1

Well, check my code again, i remade it again ๐๐๐

+1

Thanks, i did it๐

0

Let me try it . Thanks

0

Try it. If that's the thing you wanna get๐ค

0

Thanks so much it so good to people like you

0

Hi Nazeek after some tinkering I managed to make add all integers up to n https://code.sololearn.com/WX2Dfe1JckHG/?ref=app

0

Yeap, thats kinda smart๐ I think you can also do it available for users to choose a number. The easiest way is to use "prompt" i guess ๐ค๐ค

0

Iam still still a novice to be honest. I don't know how it's done

0

Nazeekk please, stop using expletives anywhere.

0

Wow๐ That's a function to get user input. Just like: let x = prompt() alert(x) So here when we enter data, the "x" variable will have user's value

0

Nazeekk Let me incorporate that into my code thanks

0

Check my link again. I remade it๐๐ So.. as i can get, you made smth kinda "factorial calculator"?๐ค

0

0

Wow ๐ it works