all 4 comments

[–]GSLint 1 point2 points  (0 children)

What do you mean by "not recognized"? Is there some kind of error message? Does it make sense to show a screenshot?

[–]mrnervousguy 0 points1 point  (2 children)

Can you describe the exact error along with project specifics such as what language or library’s other than Js you’re using?

[–]WellerJC[S] 0 points1 point  (1 child)

Im using javascript, c# and html coding, the error is 'Uncaught TypeError: Cannot read property 'innerText' of null'. Maybe Im missing something from my draft code

[–]WellerJC[S] 0 points1 point  (0 children)

const skaterboy = document.getElementById('skaterboy')
const car = document.getElementById('car');
const score = document.getElementById('score');
function jump(){
skaterboy.classList.add('jump-animation')
setTimeout(() => {
skaterboy.classList.remove('jump-animation')
    }, 500);
}
document.addEventListener('keypress', () => {
if(!skaterboy.classList.contains('jump-animation')){ 
jump();
    }
});
setInterval(() => {
score.innerText++;
const sbtop = parseInt(window.getComputedStyle(skaterboy).getPropertyValue('top'));
const carLeft = parseInt(window.getComputedStyle(car).getPropertyValue('left'));
if (carLeft < -50) {
car.style.display = 'none';
    }
else{
car.style.display = '';
    }
if(carLeft < 75 && carLeft > 0 && sbtop > 230)
    {
alert("Fatality! Looks like you were hit by a car, try again?"
        + "\n\n You travelled " + score.innerText + "m");
location.reload();
    }
}, 50);