Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const testWrapper = document.querySelector(".test-wrapper");
- const testArea = document.querySelector("#test-area");
- const originText = document.querySelector("#origion-text p").innerHTML;
- const resetButton = document.querySelector("#reset");
- const theTimer = document.querySelector(".timer");
- var timer = 0;
- function startTimer {
- let textLength = testArea.value.length;
- if(textlength == 0){
- timer++;
- theTimer.innerHTML = timer;
- }
- }
- testArea.addEventListener("keypress", startTimer, false);
- testArea.addEventListener("keyup", checkSpelling, false);
- function checkSpelling{
- let textEntered = testArea.value;
- let originTextMatch = originText.subString(0, textEntered.length);
- if(textEntered == originText){
- testWrapper.style.borderColor = "#00FF11";
- }else{
- if(textEntered == originTextMatch){
- testWrapper.style.borderColor = "#1500FF"
- }else{
- testWrapper.style.borderColor = "#FF0000"
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement