Skip to content

Showing class property value on click

I need to display the this.name in the console when clicking the button element. I could replace inside clicked() and set console.log(myBtn.name) but I’d like this method to work with any object. Is there a way to do it? When I click I get an empty string. Thanks! Answer You was almost there The problem…

Adding dynamic date to a static webpage

I want my static webpage timezone needs to be relative to CST, so if client(CST) open this file it should show CST date and Myself(IST) if I open this also it should show only the CST, could anyone please help me on this HTML file- JS file- Answer You shouldn’t try to assemble a date string yourself. Bo…

Do-While loop output is undefined

the console shows undefined for the following loop. the issue is in array[i] as it says i is undefined but it is the index for the loop elements. I don’t want to change the x to I as I want to run the code only once and test that it will stop as x is not < 5. Answer so

Sum of values in javascript object

I have the following javascript object I’m trying to get the sum of all values where it says ‘prijs’ (it’s in dutch) Is there an ‘easy’ way to do this? EDIT: Thanks everyone for the amazing replies! I got it to work thanks to you guys. Answer Its not totally sexy – an…

How is the third line of code here creating a reverse array?

This function should be taking an array and reversing its order. It works but I don’t understand what the third line “for (let i = arr.length…” is doing. Can someone please explain what is being pushed to the new reversed array? Answer For the line: The for loop is starting at the last…