Category : let

When I use var in the loop I get no error. function reverseString(str) { for (var reversedStr = “”, i = str.length – 1; i >= 0; i–) { reversedStr += str[i]; } return reversedStr; } console.log(reverseString(“hello”)) //OUTPUT ——–> olleh when I use let in the loop I get an error. function reverseString(str) { for ..

Read more

I’m making a chat and I want to add an avatar pics feature so I figured it might work well with span, but the problem is I don’t know how to add the span to the element. let avatar = document.createElement("span"); let userMessage = document.createElement("H3"); avatar.setAttribute(userMessage); userMessage.innerHTML = username + ": " + message; //document.getElementById("chat").appendChild(avatar); ..

Read more

let a = ‘Fred Flinstone’; // This is a global variable function alpha() { alert(a); } alert(alpha()); why the following code displaying undefined after displaying fred flinston? and what properties does "const" in ES6 have and what is meant by " referencing to memory " in const? Thanks Source: Ask Javascript..

Read more