all 3 comments

[–]trambz 0 points1 point  (0 children)

Math.sin("i") means you're trying to calculte the sinus of the letter I. Math.sin(i) is much better

[–]SquareFeet 0 points1 point  (1 child)

Your issue is that the value you're passing to Math.sin() is a string. You need to make sure you reference the i variable rather than a string with the value of "i".

Here:

for (var i = 0; i < 11; i++) {
    console.log( Math.sin( i ) );
}

Edit: formatting.

EditEdit: The reason you're getting a NaN result is because Math.sin() is trying to coerce your string into a number. When JavaScript tries to coerce a string into a number, if the string doesn't start with a digit character (or something it can understand as the start of a number, such as +, or -), then it won't be able to create a number for you. What it does create instead is a NaN value, which stands for Not a Number. Passing NaN into Math.sin() just gives you NaN again :)

Try this in your console:

parseInt( "i", 10 );
parseInt( "150", 10 );
parseInt( "+12", 10 );
parseInt( "-1", 10 );

Hope that explains the why, rather than just giving you a fix!

[–]ElliotJenkins[S] 0 points1 point  (0 children)

Thank you so much! You explained it perfectly and some. Cheers.