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

js

3/3/2021 1:17:12 PM

Global Universe

55 Answers

New Answer

+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

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