Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMB HTML JAVA DONE TA #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
140 changes: 102 additions & 38 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,53 +1,117 @@
<!DOCTYPE html>
<html>
<head>

<head>
<link rel="stylesheet" href="./index.css">

<title>Combining HTML and JavaScript + DOM Lab</title>
</head>
<body>
<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>
<script src="index.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>
<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>

<input id="mirror-input" type="text" placeholder="Enter your string here">
<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>
<br />
<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="stringMirror()">
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>
<br />
<input id="uppercaser-input" type="text" placeholder="Enter your string here" />
<p id="uppercaser-output">Waiting for input...</p>
<button id="uppercaser-button" type="submit" onclick="stringUppercase()">
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>
<br />
<input id="palindrome-input" type="text" placeholder="Enter your string here" />
<p id="palindrome-output">Waiting for input...</p>
<button id="palindrome-button" type="submit" onclick="palindrome()">
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>
<br />
<input id="even-checker-input" type="text" placeholder="Enter your number here" />
<p id="even-checker-output">Waiting for input...</p>
<button id="even-checker-button" type="submit" onclick="isEvenChecker()">
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>
<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>
<br />
<input id="doubler-input" type="text" placeholder="Enter your number here" />
<p id="doubler-output">Waiting for input...</p>
<button id="doubler-button" type="submit" onclick="doubleNumber()">
Submit
</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>
<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>
<br />
<input id="average-input-1" type="text" placeholder="Enter your number here" /><br />
<input id="average-input-2" type="text" placeholder="Enter your number here" /><br />
<input id="average-input-3" type="text" placeholder="Enter your number here" /><br />
<p id="average-output">Waiting for input...</p>
<button id="average-button" type="submit" onclick="averageNumber()">
Submit
</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>
<br />
<input id="vowel-remover-input" type="text" placeholder="Enter your text please" />
<br />
<br />
<input type="checkbox" id="y-is-vowel-checkbox" />
<label for="vowel">Y is a vowel</label>
<p id="vowel-remover-output">Waiting for input...</p>
<br />
<button id="vowel-remover-button" onclick="removeVowels()" type="submit">
Remove vowels
</button>
</body>

</body>
</html>
</html>
86 changes: 86 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
function stringMirror() {
const input = document.getElementById("mirror-input");
const text = input.value;
const output = document.getElementById("mirror-output");
output.textContent = text;
}

function stringUppercase() {
const input = document.getElementById("uppercaser-input");
const text = input.value;
const output = document.getElementById("uppercaser-output");
output.textContent = text.toUpperCase();
}

function palindrome() {
const input = document.getElementById("palindrome-input");
const string = input.value;
const output = document.getElementById("palindrome-output");
let newString = "";
for (let i = string.length - 1; i >= 0; i--) {
newString += string[i];
}
if (string === newString) {
output.textContent = `It is true that ${string} is a palindrome`;
} else {
output.textContent = `It is false that ${string} is a palindrome`;
}
}

function isEvenChecker() {
const input = document.getElementById("even-checker-input");
const number = input.value;
const output = document.getElementById("even-checker-output");
if (number % 2 === 0) {
output.textContent = `It is true that ${number} is even`;
} else {
output.textContent = `It is false that ${number} is even`;
}
}

function doubleNumber() {
const input = document.getElementById("doubler-input");
const number = input.value;
const output = document.getElementById("doubler-output");
output.textContent = `${number} doubled is ${number * 2}`;
}

function averageNumber() {
const num1 = parseInt(document.getElementById("average-input-1").value);
const num2 = parseInt(document.getElementById("average-input-2").value);
const num3 = parseInt(document.getElementById("average-input-3").value);
let output = document.getElementById("average-output");
if (isNaN(num1) || isNaN(num2) || isNaN(num3)) {
output.textContent = "Please enter a number";
} else {
average = (num1 + num2 + num3) / 3;
output.textContent = `The average of ${num1}, ${num2}, and ${num3} is ${average}`;
}
}

function removeVowels() {
let string = document.getElementById("vowel-remover-input").value;
let output = document.getElementById("vowel-remover-output");
let checkbox = document.getElementById("y-is-vowel-checkbox");
let vowel = "aeiouyAEIOUY";
let newStr = "";
if (checkbox.checked) {
for (let i = 0; i < string.length; i += 1) {
if (!vowel.includes(string[i])) {
newStr = newStr + string[i];
} else {
newStr = newStr + "";
}
}
} else {
let vowelNoY = "aeiouAEIOU";
for (let i = 0; i < string.length; i += 1) {
if (!vowelNoY.includes(string[i])) {
newStr = newStr + string[i];
} else {
newStr = newStr + "";
}
}
}
output.textContent = newStr;
}
Loading