1

Make it so it organizes strings differently from number types. i.e. [1, "2", "3", 2] should return [[1,2], ["2", "3"]]


const stringArray = [1, "2", "3", 2];

function checkArrayString(arr){
    let emptyArray = [];
    let emptyArray2 = [];
    let emptyArray3 = [];

    for(let j=0; j<arr.length; j++){
        if(arr[j]===`${arr[j]}`){                 //looping to find string values in array
            console.log("working");
            emptyArray.push(arr[j]);                
            emptyArray3.push(emptyArray);
        } else{
            console.log("see five working");
            emptyArray2.push(arr[j]);     
            emptyArray3.push(emptyArray2);
            }
    }
    return emptyArray3;
}
Barmar
  • 741,623
  • 53
  • 500
  • 612
Husky101
  • 11
  • 1

0 Answers0