I am trying to draw the cos curve using javascript. I expected to see a nice cos curve going accross the webpage. like this…

I added 200 to move the curve down so I could see the whole thing. I multiply by 100 because there are no decimal places in html. If you look at the jsfiddle it is a mess
$(function(){
for (i=0; i<500; i++){
var el = $('<div class="dot"></div>');
var y = Math.cos(i*100) * 100 + 200;
var x = i ;
el.css({ 'left' : x+'px' , 'top':y+ 'px'});
$('#main').after(el);
}
});
Trigonometric functions use radians, not degrees. To convert between degrees and radians, use the formula
Here’s an updated version of the fiddle that shows something recognizable.