Step 35 and step 36 glitching, even when it’s working. Here’s the code:
const userInput = document.getElementById('user-input');
const checkBtn = document.getElementById('check-btn');
const resultsDiv = document.getElementById('results-div');
const theclear = document.getElementById("clear-btn");
const pf1= /1 \([1-9][1-9][1-9]\) [1-9][1-9][1-9]-[1-9][1-9][1-9][1-9]/;
const pf2= /\([1-9][1-9][1-9]\)[1-9][1-9][1-9]-[1-9][1-9][1-9][1-9]/
const pf3= /[1-9][1-9][1-9]-[1-9][1-9][1-9]-[1-9][1-9][1-9][1-9]/;
const pf4= /[1-9][1-9][1-9][1-9][1-9][1-9][1-9][1-9][1-9][1-9]/;
const pf5= /1 [1-9][1-9][1-9] [1-9][1-9][1-9] [1-9][1-9][1-9][1-9]/;
const pf6= / 1\([1-9][1-9][1-9]\)[1-9][1-9][1-9]-[1-9][1-9][1-9][1-9]/;
const pf7= /1 [1-9][1-9][1-9]-[1-9][1-9][1-9]-[1-9][1-9][1-9][1-9]/;
const wrong= /^(?!1$)\d{2,} [1-9][1-9][1-9]-[1-9][1-9][1-9]-[1-9][1-9][1-9][1-9]/;
const wrong2= /\([1-9][1-9][1-9]-[1-9][1-9][1-9]-[1-9][1-9][1-9][1-9]/;
const wrong3= /^(?!1$)\d{1,}\([1-9][1-9][1-9]\)[1-9][1-9][1-9]-[1-9][1-9][1-9][1-9]/;
theclear.addEventListener("click", function(){
resultsDiv.innerHTML = "";
});
checkBtn.addEventListener("click",function(){
if(userInput.value===""){
alert("Please provide a phone number");
}else if(userInput.value.charAt(0)==="-"){
resultsDiv.innerHTML="Invalid US number: "+userInput.value;
}else if(pf1.test(userInput.value)||pf2.test(userInput.value)||pf3.test(userInput.value)||pf4.test(userInput.value)||pf5.test(userInput.value)||pf6.test(userInput.value)||pf7.test(userInput.value)){
if(wrong.test(userInput.value)||wrong2.test(userInput.value)||wrong3.test(userInput.value)){
resultsDiv.innerHTML="Invalid US number: "+userInput.value;
}else{
resultsDiv.innerHTML="Valid US number: "+ userInput.value;
}
}else{
resultsDiv.innerHTML="Invalid US number: "+userInput.value;
}
});
// Valids: 1 555-555-5555,
//1(555) 555-5555, 5555555555, 555-555-5555,
//(555)-555-5555, 1(555)555-5555
//, 1 555 555 5555, 1 456 789 4444.