Skip to content

Tag: javascript

Images not displaying on dynamic generated content

I’m working on uploading multiple images one at a time by dynamically generating the input field and image element. However, my code doesn’t display the images on the dynamically generated image element. Answer Instead of making event handler for all files use can just one event handler and then i…

How does work LexicalEnvironment and VariableEnvironment?

In first example, I expected to see undefined instead 3. Why does console show 3 in first example? Is it related with LexicalEnvironment and VariableEnvironment? and Answer Why does console show 3 in first example? num is already declared in the environment, as parameter. Hence the var num statement is ignore…

JavaScript triangle wrong direction how to make it correct?

I have a javascript question, I want to make a Triangle like this this is my code which makes opposite direction I wanna use for loop to make this triangle down bellow instead of using “repeat”. Answer You can write it like this: This method can be used in all other programming languages, cause th…

Switch…case in JS

This simple problem gives me an error. Does not get the correct answer. I will be glad if you help. Output: You did not pass Answer this way can you explain why we write true? – Hussein Nadjafli (PO) The JS switch only works on strict equality. is equivalent to in your code you replace the possible values [’x…

How to set the origin for a div?

Let’s say I have a div that follows the mouse cursor on my screen. This is done by handling the document mousemove event and setting its left and top position based on the event data. For this example let’s say it has a width and height of 10. It is desired for it to always be centered on the curs…