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

284
Vistas
Can I get all elements of an array as separate strings?

Like the title says, I want to get every element of an array as its own string in order to check if a certain other array includes any of the strings from array 1.

I feel like I've been trying at this forever and I'm not sure if it's even possible but I could just be stupid. Any help would be greatly appreciated!

const v = items.map((value) => {
        if(value.tags.includes('weapon')) return value.id
})
const results = v.filter(e => {
    return e !== undefined
})
const c = Object.keys((challengerItems)).map((key) => {return key})
const o = Object.keys((opposerItems)).map((key) => {return key})

const va = results.filter(element => {
    return element
});

if(challengerItems === undefined) return message.reply(`\`❓\` <@${message.author.id}> does not have any weapons! Duel canceled!`)
if(opposerItems === undefined) return message.reply(`\`❓\` <@${opposer.id}> does not have any weapons! Duel canceled!`)

if(!c.includes(CHECK IF USER HAS ANY WEAPONS)) return message.reply(`\`❓\` <@${message.author.id}> does not have any weapons! Duel canceled!`) 
if(!o.includes(CHECK IF OTHER USER HAS ANY WEAPONS)) return message.reply(`\`❓\` <@${opposer.id}> does not have any weapons! Duel canceled!`) 
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use map to convert every element to string (I used toString() one could JSON.stringify if that suits)

Use find and indexOf to locate items from array 2 that are included in array 1

var arr1 = [2, 17, 'B'];

var arr2 = ["18", "17", "dog"];

// convert arr1 elements to string
arr1 = arr1.map(item => item.toString())

console.log(arr2.find(item => arr1.indexOf(item) > -1))

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