const classNames = [
"Ben",
"Emma",
"Sophia",
"William",
"Elijah",
"James",
"Lucas",
"Mason",
"Mia",
"Liam",
"Noah",
"Oliver",
"Ethan",
"Harper",
"Evelyn",
];
function separateNamesWithAFromRest(classNames) {
let hasA = false;
let doubleArray = [[], []];
for (let name of classNames) {
for (let char of name) {
char = char.toLowerCase();
if (char === 'a') {
hasA = true;
} else if (char !== 'a') {
hasA = false;
}
}
}
return doubleArray;
}
I want to only use the for loops to check the names and see if the letter A exists. If it does I want to force the name into one array of the doubleArray or what can sometimes be called a “Matrix” in Javascript.