I want to import a array from a js file and it doesn't work. My code :
import * as dollarsValue from './index.js';
function intiualAdaptedVal(arr1, arr2, arrCid) { // arr1 => changeArr ; arr2 => dollarsValue
let num;
for (let i = 0; i < arr2.length; i++) {
num = getNumber(arr2, arr2[i][1]) / arrCid[i][1];
arr1[i].push(num.toFixed(2));
}
return arr1;
}
console.log(intiualAdaptedVal(changeArr, dollarsValue, cid))
Thanks you
Since you are using the ES module, you have to add
"type": "module",
in package.json
On 'index.js':
module.exports = { dollarsValue }
and for recalling in another file:
const arrayIndex = require('./index.js')
let array = arrayIndex.dollarsValue