How do I define my return value in a while table?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CBernard
    New Member
    • Jul 2012
    • 2

    How do I define my return value in a while table?

    IMPORTANT: This is a homework assignment, so I am not looking for someone to write my code, just looking for guidance on structure.

    My JavaScript table generates exactly as I want, but my code is missing the return value and is therefore giving me an undefined comment in addition to the table. I have tried nesting it all within another function, which I assign to the return value, but no change.


    Code:
    function Trig()	{	
    	
    	var d, x, decSin, decCos;
    	d = 0;  // radians
    
    	while (d <= 360) 
    	{
    		x = Math.PI/180*(d);
    
    		decSin = Math.sin(x);
    		decCos = Math.cos(x); //
    
    		document.write("<tr><td>" + d + "</td><td>" + decSin + "</td><td>" + decCos + "</td></tr>");
    
    		d = d+15;
    	}	
    }
    Last edited by CBernard; Jul 13 '12, 02:25 PM. Reason: Add comment.
  • CBernard
    New Member
    • Jul 2012
    • 2

    #2
    Got it

    I added before the function closing bracket:

    d='';
    return d;

    Comment

    Working...