Skip to content

Show the content of the function in the div

How do I show myFunction content in myDiv div? So show “Example”? Answer This code: Should be this: With the id tag inside <p> And this: Should also get called since it is a function and not just the document.getElementById(“demo”).innerHTML = “Example!”; Example 1: E…

trying to understand async / await / sync in node

i know this probably has been asked before, but coming from single-threaded language for the past 20 years, i am really struggling to grasp the true nature of node. believe me, i have read a bunch of SO posts, github discussions, and articles about this. i think i understand that each function has it’s …

UseState renders me the previous state

I have two inputs that change the text of a P tag at the same time, but the problem is that the render that shows me is always the previous value that was saved. I understand that I have to use a useEffect to render the component again and show the current value, but in the inputs handleChange if or

Javascritpt – Looping through an array

So i just started learning js and i can’t solve this excercise: Create a file named looping-through-arrays.js. In that file, define a variable named pets that references this array: [‘cat’, ‘dog’, ‘rat’] Create a for loop that changes each string in the array so that …

JavaScript – img caption to appear/disappear onclick event

I need to have image caption to appear on 1 mouse click and disappear on next click by using JS. I can’t figure out why the image caption is not appearing when I click on the image with onclick event and function use on external JS. Sorry if I make any mistake on question as this is my first post