Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function table(arr){
- console.log('<table>');
- console.log('<tr><th>Price</th><th>Trend</th></tr>');
- console.log('<tr><td>' + parseFloat(arr[0]).toFixed(2) + '</td><td><img src="fixed.png"/></td></td>')
- for (i = 0; i < arr.length - 1; i++) {
- console.log('<tr><td>' + parseFloat(arr[i + 1]).toFixed(2) + '</td><td><img src="' + trend(arr[i], arr[i + 1]) + '"/></td></td>')
- }
- function trend(num1, num2){
- num1 = parseFloat(num1).toFixed(2)
- num2 = parseFloat(num2).toFixed(2)
- if (num1 == num2) {
- return 'fixed.png';
- }
- else if (num1 < num2){
- return 'up.png'
- }
- else{
- return 'down.png'
- }
- }
- console.log('</table>')
- }
- 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