About js findIndex

Why does console come out as undefined?

var ages = [3, 10, 18, 20];

function zxc(data, dataArray){
    dataArray.findIndex(function(element){
        return element == data;
    });
}

console.log(zxc(18, ages))  //undefined

it"s no problem to write like this

    
    var ages = [3, 10, 18, 20];
    var zxc = ages.findIndex(function(element){
        return element == 18;
    });
    console.log(zxc)  //2
Apr.14,2022

The scope of

return is the most recent function
you are referring to

. The
  

function itself does not return a value

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b347da-342e5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b347da-342e5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?