Advertisement
-Annie-

ColorfulNumbers

May 25th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function nums(n) {
  2.     let html = '<ul>\n';
  3.  
  4.     for (let i = 1; i <= n; i++) {
  5.       let color = 'blue';
  6.       if (i % 2 != 0) color = 'green';
  7.       html += ` <li><span style='color:${color}'>${i}</span></li>\n`;
  8.     }
  9.  
  10.     html += '</ul>';
  11.  
  12.     return html;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement