Yngvarr

Generation

generate functionFri, 14 Apr 2023

search in array

function search(array, key){ let index = 0; while(index < array.length){ if(array[index] === key){ return index; } index = index + 1; } return -1; } search([1, 2, 3], 2);

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant