I am trying to assign the element with the lowest count into a new array property lowestAlph and give me the below iteration where -2 is being stored, instead of simply outputting the lowest count -2 on its own :
[["n"], ["o", "p"], ["q"], ["r", "s"], -2]
However, it's not printing the correct output with the push method.
Could someone please help?
const example = {
alph: [
[["a"], ["b", "c"], ["d"], ["e", "f"], 23],
[["g"], ["h", "j"], ["k"], ["l", "m"], 19],
[["n"], ["o", "p"], ["q"], ["r", "s"], -2],
[["t"], ["u", "w"], ["x"], ["y", "z"], 25]
],
lowestAlph: [],
calcLow: function () {
let lowest = this.alph[0][4];
for (let i = 0; i < this.alph.length; i++) {
for (let n = i + 1; n < this.alph.length; n++) {
if (this.alph[n][4] < lowest)
lowest = this.alph[n][4]
}
//this.lowestAlph.push(this.alph[i])
}
return lowest;
}
}
console.log(example.calcLow());