Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
121 changes: 100 additions & 21 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,53 +1,132 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="./index.css">
hello
<link rel="stylesheet" href="./index.css" />
<title>Combining HTML and JavaScript + DOM Lab</title>
<script src="./lab.js"></script>
</head>
<body>
<h1 id = "top_heading">Combining HTML and JavaScript + DOM Lab</h1>
<p id = "welcome_para">Complete each of the sections below</p>
<h1 id="top_heading">Combining HTML and JavaScript + DOM Lab</h1>
<p id="welcome_para">Complete each of the sections below</p>
<h2>1. String Mirror</h2>

<ul>
<li>Make a text input with id='mirror-input' and a button with id='mirror-button'</li>
<li>They should then be able to click a "submit" button that will display the string the user entered in an element with id='mirror-output'</li>
</ul>
<li>
Make a text input with id='mirror-input' and a button with
id='mirror-button'
</li>
<li>
They should then be able to click a "submit" button that will display
the string the user entered in an element with id='mirror-output'
</li>
</ul>

<input id="mirror-input" type="text" placeholder="Enter your string here">
<input id="mirror-input" type="text" placeholder="Enter your string here" />
<p id="mirror-output">Waiting for input...</p>
<button id="mirror-button" type="submit">Submit</button>
<button id="mirror-button" type="submit" onclick="mirrorStr()">
Submit
</button>

<h2>2. String Uppercaser</h2>

<li>Make a text input with id='uppercaser-input'</li>
<li>They should then be able to click a "submit" button with id='uppercaser-button' that will display the string the user entered in all uppercase in an element with id='uppercaser-output'</li>
<li>
They should then be able to click a "submit" button with
id='uppercaser-button' that will display the string the user entered in
all uppercase in an element with id='uppercaser-output'
</li>

<input id="uppercaser-input" type="text" />
<p id="uppercaser-output"></p>
<button id="uppercaser-button" type="submit" onclick="stringUpperCaser()">
Submit
</button>
<h2>3. Palindrome Detector</h2>

<li>The user should be able to enter a string into a text input with id='palindrome-input'</li>
<li>They should then be able to click a "submit" button with id='palindrome-button'. Clicking the button will display a string in the form "It is ${true/false} that ${entered string} is a palindrome" with id='palindrome-output'</li>
<li>
The user should be able to enter a string into a text input with
id='palindrome-input'
</li>
<li>
They should then be able to click a "submit" button with
id='palindrome-button'. Clicking the button will display a string in the
form "It is ${true/false} that ${entered string} is a palindrome" with
id='palindrome-output'
</li>

<input id="palindrome-input" type="text" />
<p id="palindrome-output">String will appear here</p>
<button id="palindrome-button" onclick="palindromeDetector()" type="submit">
Submit
</button>

<h2>4. Even Checker</h2>

<li>The user should be able to enter a number into an input with id='even-checker-input'</li>
<li>They should then be able to click a "submit" button with id='even-checker-button' that will display a string in the form "It is ${true/false} that ${entered number} is even" with id='even-checker-output'</li>
<li>
The user should be able to enter a number into an input with
id='even-checker-input'
</li>
<li>
They should then be able to click a "submit" button with
id='even-checker-button' that will display a string in the form "It is
${true/false} that ${entered number} is even" with
id='even-checker-output'
</li>
<input id="even-checker-input" type="text" />
<p id="even-checker-output"></p>
<button id="even-checker-button" onclick="evenChecker()" type="submit">
Submit
</button>

<h2>5. Number Doubler</h2>

<li>The user should be able to enter a number into an input with id='doubler-input'</li>
<li>They should then be able to click a "submit" button with id='doubler-button' that will display a string in the form "${entered number} doubled is ${doubledVal}" with id='doubler-output'</li>
<li>
The user should be able to enter a number into an input with
id='doubler-input'
</li>
<input id="doubler-input" type="text" />
<li>
They should then be able to click a "submit" button with
id='doubler-button' that will display a string in the form "${entered
number} doubled is ${doubledVal}" with id='doubler-output'
</li>
<p id="doubler-output"></p>
<button id="doubler-button" onclick="doubler()"></button>

<h2>6. Average of Three Numbers</h2>

<li>The user should be able to enter 3 numbers into text inputs with ids 'average-input-1', 'average-input-2', and 'average-input-3'</li>
<li>They should then be able to click a "submit" button with id='average-button' that will display a string in the form "The average of ${numberOne}, ${numberTwo}, and ${numberThree} is ${average}" with id='average-output'</li>
<li>
The user should be able to enter 3 numbers into text inputs with ids
'average-input-1', 'average-input-2', and 'average-input-3'
</li>
<input id="average-input-1" type="text" />
<input id="average-input-2" type="text" />
<input id="average-input-3" type="text" />
<li>
They should then be able to click a "submit" button with
id='average-button' that will display a string in the form "The average of
${numberOne}, ${numberTwo}, and ${numberThree} is ${average}" with
id='average-output'
</li>
<p id="average-output"></p>
<button id="average-button" type="submit" onclick="findAvg()"></button>

<h2>Bonus: Vowel Remover</h2>

<li>The user should be able to enter a string into a text input with id='vowel-remover-input'</li>
<li>The user should be able to select or deselect a checkbox with id='y-is-vowel-checkbox'</li>
<li>They should then be able to click a "submit" button with id='vowel-remover-button' that will display the original string with all vowels removed with id='vowel-remover-output'. If the checkbox is checked, count y as a vowel. Otherwise, count y as a consonant.</li>

<li>
The user should be able to enter a string into a text input with
id='vowel-remover-input'
</li>
<li>
The user should be able to select or deselect a checkbox with
id='y-is-vowel-checkbox'
</li>
<li>
They should then be able to click a "submit" button with
id='vowel-remover-button' that will display the original string with all
vowels removed with id='vowel-remover-output'. If the checkbox is checked,
count y as a vowel. Otherwise, count y as a consonant.
</li>
</body>
</html>
54 changes: 54 additions & 0 deletions lab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const mirrorStr = () => {
const inputTag = document.querySelector("#mirror-input");
const pTag = document.querySelector("#mirror-output");
pTag.innerText = inputTag.value;
};

const stringUpperCaser = () => {
const upperCaserInput = document.querySelector("#uppercaser-input").value;
const upperCaserOutput = document.querySelector("#uppercaser-output");
upperCaserOutput.innerText = upperCaserInput.toUpperCase();
};

const palindromeDetector = () => {
const userInput = document.querySelector("#palindrome-input").value;
let pTag = document.querySelector("#palindrome-output");
for (let i = 0; i < userInput.length; i++) {
if (userInput[i] !== userInput.slice(-1 - i)[0]) {
pTag.innerText = `It is false that ${userInput} is a palindrome`;
return;
}
}
pTag.innerText = `It is true that ${userInput} is a palindrome`;
};

const evenChecker = () => {
let userNum = document.getElementById("even-checker-input").value;
let isEven = document.getElementById("even-checker-output");

if (userNum % 2 === 0) {
isEven.innerText = `It is true that ${userNum} is even`;
} else {
isEven.innerText = `It is false that ${userNum} is even`;
}
};

const doubler = () => {
let userNum = document.getElementById("doubler-input").value
let doubledNum = document.getElementById("doubler-output")

doubledNum.innerText = `${userNum} doubled is ${userNum*2}`
}

const findAvg = () => {
let num1 = Number(document.getElementById("average-input-1").value)
let num2 = Number(document.getElementById("average-input-2").value)
let num3 = Number(document.getElementById("average-input-3").value)
let avgOutput = document.getElementById("average-output")

let avg = ((num1+num2+num3) / 3)


avgOutput.textContent = `The average of ${num1}, ${num2}, and ${num3} is ${avg}`

}
Loading