Advertisement
Guest User

Untitled

a guest
Nov 19th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function table(arr){
  2.     console.log('<table>');
  3.     console.log('<tr><th>Price</th><th>Trend</th></tr>');
  4.     console.log('<tr><td>' + parseFloat(arr[0]).toFixed(2) + '</td><td><img src="fixed.png"/></td></td>')
  5.     for (i = 0; i < arr.length - 1; i++) {
  6.         console.log('<tr><td>' + parseFloat(arr[i + 1]).toFixed(2) + '</td><td><img src="' + trend(arr[i], arr[i + 1]) + '"/></td></td>')
  7.     }
  8.  
  9.     function trend(num1, num2){
  10.         num1 = parseFloat(num1).toFixed(2)
  11.         num2 = parseFloat(num2).toFixed(2)
  12.         if (num1 == num2) {
  13.             return 'fixed.png';
  14.         }
  15.         else if (num1 < num2){
  16.             return 'up.png'
  17.         }
  18.         else{
  19.             return 'down.png'
  20.         }
  21.     }
  22.     console.log('</table>')
  23.  
  24. }
  25.  
  26. table(['1.33', '1.35', '2.25', '13.00', '0.5', '0.51', '0.5', '0.5', '0.33', '1.05', '1.346', '20', '900', '1500.1', '1500.10', '2000'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement