scrimba
Note at 2:16
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 2:16
AboutCommentsNotes
Note at 2:16
Expand for more info
index.js
run
preview
console
let input = document.getElementById("string");
let counter = document.getElementById("counterFooter")
let button = document.getElementById("btn");

input.addEventListener("input", () => {
let left = 140 - input.value.length;
left < 21 ? counter.style.color = "red" : counter.style.color = "white";
left < 0 ? button.classList.add("buttonDisabled") : button.classList.remove("buttonDisabled");;

counter.innerHTML = left + "/140";
})
button.addEventListener("click", () => {
let text = input.value;
window.open("https://twitter.com/intent/tweet?text=" + text);
});
Console
/index.html
LIVE