I've searched, and I found nothing about what I am going to ask. I have a question as a beginner and a student who learns JavaScript. I know how to check if a number is a prime or not. This is my problem:
numbers([
[5, 7, 10],
[8, 2, 3],
[44, 50, 22]
])
expected output:
[
['#', '#', 10],
[8, '#', '#'],
[44, 50, 22]
]
What I need is: if there is a prime number in a multidimensional array, i need to change it to #, and if not, nothing change. This task requires no built in function such as .indexOf, .include, .findIndex, .reduce, .map, .filter, and no new parameters added, or regex. And this is what I got so far:
function multidimensionalPrimesChecker(numbers)
{
for (var i = 0 ; i < numbers.length ; i++)
{
for (var j = 0 ; j < numbers[i].length ; j++)
{
if (numbers[i][j] % i === 0)
{
return false;
}
}
}
}
And I have no idea anymore how to solve this. Help me, please. And thanks for your kindness