How do I remove the extra brackets that shows up when I console log my code?

TigerLady

Please help me remove the extra bracket that shows up when I console log. I've been trying for hours to remove it to no avail. This is my code:

let numberArray = [];
let evenNumbers = [];
let oddNumbers = [];




function findOdds(numberArray) {
    for (let i = 0; i < numberArray.length; i++) {
        if ((numberArray[i] % 2) !== 0) {
           oddNumbers.push(numberArray[i]);
        }
        else {
            evenNumbers.push(numberArray[i]);
        }
    } console.log(oddNumbers);

};




findOdds(numberArray);





findOdds([90023, 11811, 10032, 10026, 67021]); 

When I console log it I get this:

[]
[ 90023, 11811, 67021 ]

How do I remove that extra first bracket?

Clément Boschet

You can delete this line :

findOdds(numberArray);

You run your function twice and the first bracket is logged here when you're running your function with an empty array as parameter.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I remove the 'b' prefix when my message is printed?

Microsoft VS Code: When I try to launch my program error "spawn php ENOENT" shows up

How do I make it so that the countdown shows up on the tkinter window instead of in my cmd?

How do I remove this extra span height?

How do i remove a like from a photo in my code

How do I remove brackets and bracketed contents?

When are my post requests being fired based on woocomerce events, and how do I console my php code so I can debug

my console.log() shows up twice in my chrome console

How do I stop my code from printing the extra question?

Why does JavaScript round up this number when I log it to the console?

Sed - How do I remove the extra characters that show up after running the command?

extra numbers showing up on my axes when i do multiple subplots in matplotlib

How do I disable the console LOG on eclipse

How do i remove white border from my code for website?

I get an extra input space when I run my code

How do I fix this strange screen that shows when I turn my Debian computer on?

MATLAB GUI - How do I remove the CreateFcn callback in my code?

How do I remove extra space in python?

How do I remove comma and brackets

When I run this code only the Splitpane shows up but not the JMenu

how do i get rid of the zero that shows up after all my elements in my array are listed?

How do I remove these extra arrows from my output?

How do I log the dates in the console as I am trying to do in this code snippet?

How do I see the console.log in this code?

When ever I run my code this pops up : Event { isTrusted: [Getter] } what do i do?

when i fill a form input it shows the previous value in console log

how do i call my variable so that it shows up on my react web app

How do I remove this extra kite from the diamond in this code?

When I run my while loop, nothing shows up