Hi! So I want to get the following result: enter image description here
and here's the js function that i wrote. The problem is that the output of my function is null.
function dataTypeArray(arr, type){
for(i=0; i<=arr.length-1; i++)
var string = [];
var number = [];
var boolean = [];
var i;
if(type = 'string' && typeof arr[i] == 'string'){
string.push(arr[i]);
} else {
if(type = 'number' && typeof arr[i] == 'number'){
number.push(arr[i]);
} else {
if(type = 'boolean' && typeof arr[i] == 'boolean'){
boolean.push(arr[i]);
} else {
return 'null';
}}}
return string, number, boolean;}
var arr = ['hhg', 'fthth', 456, true];
console.log(dataTypeArray(arr, 'string'));