skip to Main Content

array filter in javascript value coming as not expected

<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> const secret = [ {key:'1'}, {key:'2'} ]; document.getElementById("demo").innerHTML = secret.filter((value)=>{return value.key>1}); </script> </body> </html> I am expecting output should be the second object in the array as key:2. Which part I am trying…

VIEW QUESTION
Back To Top
Search