JSFiddle - React, Tailwind, and code Playground
by humanzing
JavaScript
let last_price_table = [];
add_data("btcusdt",10000);
function add_data(ticker,price)
{
var data = {"ticker":ticker,"price":price};
last_price_table.push(data);
console.log(last_price_table);
last_price_table.find(v => v.ticker == ticker).price = 5000;
console.log(last_price_table);
}
function update_data(ticker,price)
{
last_price_table.find(v => v.ticker == ticker).price = 5000;
}
function check_horn(ticker,price,d)
{
if(d = "<")
{
if( last_price_table.find(v => v.ticker == ticker).price >= price)
{
return true;
}
else
{
return false;
}
}
else if(d = ">")
{
if( last_price_table.find(v => v.ticker == ticker).price <= price)
{
return true;
}
else
{
return false;
}
}
else
{
}
}