Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Error: Bad arguments: First argument should be a string, second should be an array of strings #123

Open
DancingPotatoes opened this issue Nov 18, 2021 · 3 comments

Comments

@DancingPotatoes
Copy link

I am pretty sure I did it correctly I have the first as a string and the second as an array the code is

const pokemons = require('../../arrays/pokemons.js')
const poss = stringSimilarity.findBestMatch(args, pokemons)

arrays file

exports.pokemons = [
	pokemon lists
]
@alvaroaac
Copy link

This is very hard to debug. What's in args? Can you give an example of the pokemon lists?

@spuggle
Copy link

spuggle commented Dec 18, 2021

What you've done here is assigned your array to the pokemons property on the exports object:

exports.pokemons = [
	pokemon lists
]

When importing a module, it's export object is what you receive, so you'll need to access the pokemons property from the imported object to actually get the array you intended to work with. So you'll want something like (for ES6+):

const { pokemons } = require('../../arrays/pokemons.js')
const poss = stringSimilarity.findBestMatch(args, pokemons)

@hoangvu12
Copy link

How is this an issue? The is skill problem. The author don't understand how exports work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants