I'm using Webpack, and I have a function.js file with this code:
import { randomNum } from '../index.js';
export function getSlidePrev() {
if (randomNum > 1) {
randomNum -= 1;
setBg(randomNum);
}
}
And in my main.js file I have this:
function getRandomNum(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
export let randomNum = getRandomNum(firstSlideNumber, lastSlideNumber);
const slidePrev = document.querySelector('.slide-prev');
slidePrev.addEventListener('click', getSlidePrev);
I get this type of error:
Uncaught TypeError: Cannot set property randomNum of #<Object> which has only a getter
at HTMLButtonElement.getSlidePrev
I tried to google, but I couldn't solve this issue. Someone says it's because of using Babel.