In my post request, I want to check if thisString exists in another javascript file array.
Array.js
exports.names = [
'John',
'Mary'
]
Main.js
if (names.includes(thisString)) {
...do stuff...
}
if thisString = Mary, Main.js returns "undefined". If I console.log(names) it returns the array. But console.log(names[0]) is undefined. And If I copy and paste the array into the Main.js file it works as intended.
I want to have the array in another file just to clean things up a bit. But what am I doing wrong?
namesin Main.js?const names = require('../array');