Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Best Stock by laoshu133
import assert from "assert";
function bestStock(data: object): string {
return Object.keys(data).sort((a, b) => data[b] - data[a])[0];
}
console.log('Example:');
console.log(bestStock({'ATX': 390.2,
'CAC': 10.0,
'WIG': 1.2}));
// These "asserts" are used for self-checking
assert.equal(bestStock({'ATX': 390.2,
'CAC': 10.0,
'WIG': 1.2}), 'ATX');
assert.equal(bestStock({'ATX': 1.01,
'CAC': 91.1,
'TASI': 120.9}), 'TASI');
console.log("Coding complete? Click 'Check' to earn cool rewards!");
July 6, 2021