string-similarity
string-similarity copied to clipboard
Error: Bad arguments: First argument should be a string, second should be an array of strings
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
]
This is very hard to debug. What's in args? Can you give an example of the pokemon lists?
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)
How is this an issue? The is skill problem. The author don't understand how exports work.