Setup
Implement a function that will accept an array of integers and an integer n. Find all occurrences of n in the given array and retu...
For further actions, you may consider blocking this person and/or reporting abuse
JavaScript
In Python:
The commented out array line would allocate a new array to meet the specification.
Haskell
Written on the phone, it might not work, I'll check it when I get home.
Haskell:
or alternatively,
Rust:
In Dart:
dartpad.dev/
Swift:
Elm
Implementation.
In JavaScript:
function find_all1(arr, n){
let arr1 = [];
arr.forEach((item,index) => {
item === n ? arr1.push(index): null;
});
console.log(arr1);
}
find_all1([6,9,3,4,3,82,11],3);
Ruby
js
PHP
<?php function find_all($array,$number){
return array_keys($array,$number);
}
var_dump(find_all(array(6, 9, 3, 4, 3, 82, 11), 3) );