'in the program below I have to pass 2 parameters as in update method 1st one to check the stored value & second to update the value in Javascript

how can I update a value in the array of objects?

     class Person{
     data = []   // defining an array
     constructor(fname, lname, gender){
         this.data = [
             {
                 fname,
                 lname,
                 gender
         } 
         ] 
     }
     add(fname, lname, gender){
        this.data.push([{fname, lname, gender}]);
     }
     list(){
         return console.log(this.data);
     }
     delete(fname, lname, gender){
         this.data.pop([{fname, lname, gender}]);
     }
     update(){
         return 0;
     }
    }
     let p = new Person()    
     p.add("aakash", "sharma", "male");
     p.add("chirayu", "mehta", "male");
     p.list()
     p.update()

we need to pass 2 parameters in the update method which updates the value in the array.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source