why is my js script not displaying timer result?

I’m making a countdown timer hours minutes and second but the script I’m running doesn’t display the results I wrote in the js script, can anyone correct my code so that the timer can work? The problem let countdown = new date().getHours() let $hours = document.getElementById(‘hours’); let $minutes = document.getElementById(‘minutes’); let $second = document.getElementById(‘second’); setInterval(function()… Read More why is my js script not displaying timer result?

Beginner Question: Why is this inner for loop not incrementing in JS?

Not sure if looking at code all day is making me blind, beside my natural ignorance, but I can’t find out why I cannot get the inner look to throw its next item into finalDataset. The intent is to generate a new array with some modifications. Appreciate any help. const arr1 = [ [“Header1”, “Color”,… Read More Beginner Question: Why is this inner for loop not incrementing in JS?

Why can't I use querySelector on a parentElement which I know has the queried class

I can traverse to reach my target element like this: this.parentElement.parentElement.style.backgroundColor = ‘red’; But why does this not work even though I know for a fact that the second parentElement has the .container class: this.parentElement.parentElement.querySelector(‘.container’).style.backgroundColor = ‘red’; Shouldn’t .querySelector start the search from the current element? Example code: document.querySelectorAll(‘button’).forEach(btn => { btn.addEventListener(‘click’, function(){ //works: //this.parentElement.parentElement.style.backgroundColor… Read More Why can't I use querySelector on a parentElement which I know has the queried class

JavaScript regex.exec() should intended to use an assembled regEx

if I use ( https://jsfiddle.net/fgsvzn4a/ ) : var text = "ui1pu"; var regExParameter = ‘\d+’; var regEx = ‘/(.*)’ + regExParameter + ‘(.*)/gi’; var matches = regEx.exec(text); if(matches && matches[1]) { var str1 = matches[1]; var str2 = matches[2]; var newStr = str1 + str2 console.log(newStr); } i get this error: Paused on exception TypeError:… Read More JavaScript regex.exec() should intended to use an assembled regEx

find all the items in the list and console.log them wuth url

I am trying to return all of the items in this html list (name and url_. I can console.log and find one item, but my console.log isn’t working to retrieve all of them at once. document.getElementsByClassName(‘vxl-filelink-text’); var sampleX = document.getElementsByClassName(‘vxl-filelink-text’); sampleX[0].innerHTML; sampleX[0].href; //need a for loop to get all this data in the console for… Read More find all the items in the list and console.log them wuth url

eventlistener once property prevents other eventlistener issue

constructor() { document.addEventListener("keyup", this.keyStart.bind(this), {once:true}); document.addEventListener("keydown", this.keySpaceHandler.bind(this)); } keySpaceHandler(e) { if (e.keyCode === 32 && missile_count > 0) { …. } } keyStart(e) { if (e.key === "ArrowLeft" || e.key === "ArrowRight") { isGameStart = true; if (isGameStart === true) { … } } } I want keyStart to listen to the event only once… Read More eventlistener once property prevents other eventlistener issue

The consolidated results containing only one item, while expecting to have more than one

Question: Sorry if I cant summarize the problem in a nut shell, so I try to explain it in details. I try to construct a object by using a input. However my consolidated results containing only one item, while expecting to have more than one. Q2:In addition to the bug, may I seek for a… Read More The consolidated results containing only one item, while expecting to have more than one