A noob coder here. I'm trying to get into JavaScript and it doesn't like the idea. My main issue is that apostrophes in JS does not work on my computer. click for img
let images = [...document.querySelectorAll('.img')];
let slider = document.querySelector('.slider');
let sliderWidth;
let imageWidth;
let current = 0;
let target = 0;
let ease = .05;
images.forEach((img, idx) => {
img.style.backgroundImage = 'url(./images/${idx+1}.jpeg)'
});
function lerp(start, end, t){
return start * (1-t) + end * t;
}
function setTransform(el, transformat){
el.style.transform = transform;
}
function init(){
sliderWidth = slider.getBoundingClientRect().width;
imageWidth = sliderWidth / images.lengh;
document.body.style.height = '${sliderWidth - (window, innerWidth - window, innerHeight)}px'
}
Double quote single quote doesn't matter. At first I was using Atom, so I downloaded script, doesn't work. I've tried Sublime Text, also didn't work. Now I'm trying visual studio, it does not work...
I'm really lost as to how to fix the problem. My specs are: MacBook Pro 2015 Catalina 10.15.7, using Visual Studio, and my browser is Safari.
Please help!
You have to use the " ` " symbol instead of " ' " in order to make it work.
So :
`${sliderWidth - (window, innerWidth - window, innerHeight)}px`
Look here for a similar question already solved: How do I concatenate a string with a variable?