Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

289
Views
i created two functions, both are working but when i when i put them together they are not

the below function checks if a number is odd or not and logs them

function OddNumFinder(x) {
    if (x%2==1) {
    y = console.log(x+' is a odd number');
    x = x%2
    return console.log(x);
    }
}
im_num = []

this function create an array of random number

function collConjecture(x) {
    while (x !== 1) {
        if (x%2 == 1) {
            x = (x*3)+1
        } else {
            x = x/2
        }
        im_num.push(x)
    }
}

this works

collConjecture(26)
list = im_num
console.log(list);

i don't know what i'm doing wrong here

var yetha = OddNumFinder(collConjecture(26))
console.log(yetha);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Do the following changes

//Takes a number and checks for odd
function OddNumFinder(x) {
  if (x%2 == 1) {
    console.log(x + ' is a odd number');
    x = x%2
  }
}


function collConjecture(x) {
  im_num = []
  while (x !== 1) {
      if (x%2 == 1) {
          x = (x*3)+1
      } else {
          x = x/2
      }
      im_num.push(x)
  }
  return im_num
}

//call map on each number to check for odd
collConjecture(26).map(item => {
  OddNumFinder(item)
})

Output :-

13 is a odd number
5 is a odd number
1 is a odd number
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!