Search code examples
javascriptnashorn

javascript "include()" function not working on nashorn


I tried to run the following javascript code on nashorn engine.

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.toString();
fruits.include("Orange");

But it gives the following error

"TypeError: fruits.include is not a function in at line number 3"

Please tell me how to fix this issue .


Solution

  • Not include, but includes. At the end s.

    var fruits = ["Banana", "Orange", "Apple", "Mango"];
    
    console.log(fruits.includes("Orange"));