-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
24 lines (21 loc) · 759 Bytes
/
app.js
File metadata and controls
24 lines (21 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$(document).ready(function() {
var api_url = 'https://financialmodelingprep.com/api/v3/quote/%5EDJI?apikey=0b7380f5128299e18db2b192be9d7ebf'
$.ajax({
url: api_url,
contentType: "application/json",
dataType: 'json',
success: function(result){
var dow = result[0].price;
$('.today').html( formatNumber(dow) );
var high = 29568.57;
var diff = Math.floor(dow - high);
var percent = Math.floor( (diff / high) * 100) ;
$( '.precent' ).html( percent + '%' );
$( '.diff' ).html( diff );
}
})
}
);
function formatNumber(num) {
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')
}