Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Best Stock by mortonfox
import assert from "assert";
function bestStock(data: object): string {
return Object.entries(data).reduce((best, current) => current[1] > best[1] ? current : best)[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!");
Oct. 11, 2020