I have a collection of variables stored in an array. My goal now is to identify and extract the variables with the highest values, then store them in a separate array.
This task pertains to a JavaScript program that I am developing for my daughter's Wix website.
var kiara = 1;
var rodeo = 3;
var calypso = 3;
var balthazar = 3;
var mistral = 4;
var saya = 4;
var luna = 4;
var points = [{kiara}, {rodeo}, {calypso}, {balthazar}, {mistral}, {saya}, {luna}],
Since the variables are already arranged in ascending order based on their values, the program needs to identify ties at the top position (such as mistral, saya, and luna), extract these variables along with their respective values, and save them in a new array. In cases where only one variable has the highest value, that single variable will be stored in the new array.