Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

279
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda