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

235
Vistas
i want to see if there is no repetitive day insert it into newArr that is the case (only if() part)

const arr = ["monday","tuesday","thursday","wednesday",
  "friday","saturday","sunday"];
let newArr = [];
var num = prompt('Enter number :');
for (var i = 0; i < num; i++) {
  var day = prompt('Enter day :');
  if(newArr.includes(day) !== day) newArr.push(day);
}
var num = prompt('Enter number :');
for (var i = 0; i < num; i++) {
  var day = prompt('Enter day :');
  if(newArr.includes(day) != day) newArr.push(day);
}
console.log(7 - (newArr.length));

i only want to know if() part if we entered a repetitive day like friday twice push it once into the newArr for example 1 | friday & 1 | friday ---- > 6

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you wish to check the entered day is present in the array, and if no, push the element to newArr, change your if condition to:

if(!newArr.includes(day))
{
  ...
}
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