I have a single-column array called n_fnc and I am trying to find the maximum value within it. However, my current approach does not seem to be working.
let first = this.fncs.map(item => item.n_fnc);
console.log("First",first);
x= Math.max(...first);
[
fnc service
getlastid(response,fncs:Fnc[]):void{
let fnc:Fnc;
response.forEach(element => {
fnc =new Fnc();
fnc.n_fnc=element.n_fnc;
fncs.push(fnc);
});
Fnc component.ts
this.fncs=[];
this.fncservice.obs.subscribe((response)=>this.fncservice.getlastid(response,this.fncs));
console.log("A",this.fncs);
var max= Math.max.apply(Math, this.fncs.map((m) => m.n_fnc));
console.log("Max",max);