using java script How to print the star pattern? : i want print the below star pattern using java script 

*****
 ***
  *
 ***
*****

and i am trying this code and i am getting off triangle 

below is my js code

    <!doctype html>
    <html>
    	<head></head>
    	<body>
    		<script>
    				for(i = 3;i>= 1; i--) {
    					/* Printing spaces */
    					for(j = 0; j <= 3-i; j++) {
    						document.write("&nbsp");
    					}
    					/* Printing stars */
    					k = 0;
    					while(k != (2*i - 1)) {
    						document.write("*");
    						k++;
    					}
    					
    					document.write("<br/>")
    				}
    		</script>
    	</body>
    </html>