added other units

This commit is contained in:
Benjamin Adovasio
2025-11-16 22:54:34 -05:00
parent 5bd461229a
commit ca92b603be
46 changed files with 2779 additions and 0 deletions

35
Unit 4/Day 2/script.js Normal file
View File

@@ -0,0 +1,35 @@
function program1(inputString){
document.getElementById("out1").innerHTML="";
let inputArray = Array.from(inputString);
let regex = /s/gm;
let counter = 0;
for (i = 0; i < inputArray.length; i++) {
if (regex.test(inputArray[i])) {
counter++;
}
else {
console.log("not an s");
}
}
document.getElementById("out1").innerHTML=counter;
}
function program2(inputString){
document.getElementById("out2").innerHTML="";
let inputArray = Array.from(inputString);
for (i = 0; i < inputArray.length; i++) {
if (i % 2 == 0) {
console.log("odd");
let outputCharacter = inputArray[i].toUpperCase();
let existingText = document.getElementById("out2").textContent;
document.getElementById("out2").innerHTML= existingText + outputCharacter;
}
else {
console.log("not an s");
let outputCharacter = inputArray[i].toLowerCase();
let existingText = document.getElementById("out2").textContent;
document.getElementById("out2").innerHTML= existingText + outputCharacter;
}
}
// document.getElementById("out1").innerHTML= localStorage;
}