-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55e17e2
commit 3f6181e
Showing
8 changed files
with
657 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Display largest Integer</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
color: #333; | ||
} | ||
|
||
#integerForm { | ||
max-width: 400px; | ||
margin: 0 auto; | ||
background-color: #fff; | ||
padding: 20px; | ||
border-radius: 8px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
label { | ||
font-weight: bold; | ||
color: #333; | ||
} | ||
|
||
input[type="number"] { | ||
width: 100%; | ||
padding: 8px; | ||
margin-top: 6px; | ||
margin-bottom: 10px; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
box-sizing: border-box; | ||
} | ||
|
||
button { | ||
width: 100%; | ||
background-color: #4CAF50; | ||
color: white; | ||
padding: 10px 20px; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
font-size: 16px; | ||
} | ||
|
||
button:hover { | ||
background-color: #45a049; | ||
} | ||
|
||
#result { | ||
margin-top: 20px; | ||
padding: 10px; | ||
background-color: #fff; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Max Number</h1> | ||
<form id="integerForm"> | ||
<label for="num1">Enter first integer:</label> | ||
<input type="number" id="num1" name="num1" required><br><br> | ||
<label for="num2">Enter second integer:</label> | ||
<input type="number" id="num2" name="num2" required><br><br> | ||
<label for="num3">Enter third integer:</label> | ||
<input type="number" id="num3" name="num3" required><br><br> | ||
<button onclick="findLargest(event)">Find Largest Integer</button> | ||
</form> | ||
|
||
<div id="result"></div> | ||
|
||
<script> | ||
function displayLargestInteger(num1, num2, num3) { | ||
var largest = num1; | ||
if (num2 > largest) { | ||
largest = num2; | ||
} | ||
if (num3 > largest) { | ||
largest = num3; | ||
} | ||
return largest; | ||
|
||
} | ||
|
||
function findLargest(e) { | ||
e.preventDefault(); | ||
var num1 = parseInt(document.getElementById("num1").value); | ||
var num2 = parseInt(document.getElementById("num2").value); | ||
var num3 = parseInt(document.getElementById("num3").value); | ||
var result = displayLargestInteger(num1, num2, num3); | ||
document.getElementById("result").innerHTML = "The largest integer is: " + result; | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Capitalize</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f0f0f0; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
h2 { | ||
text-align: center; | ||
color: #333; | ||
} | ||
|
||
input[type="text"] { | ||
width: 80%; | ||
padding: 10px; | ||
margin: 10px auto; | ||
display: block; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
box-sizing: border-box; | ||
} | ||
|
||
button { | ||
padding: 10px 20px; | ||
margin: 10px auto; | ||
display: block; | ||
background-color: #4CAF50; | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
|
||
button:hover { | ||
background-color: #45a049; | ||
} | ||
|
||
#output { | ||
width: 80%; | ||
margin: 20px auto; | ||
padding: 10px; | ||
background-color: #fff; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
} | ||
</style> | ||
<script> | ||
function capitalizeLastLetterOfEachWord(str) { | ||
// first i will Split the string into an array of words | ||
const words = str.split(' '); | ||
|
||
// now i will Capitalize the last letter of each word | ||
for (let i = 0; i < words.length; i++) { | ||
if (words[i].length > 0) { // Check if the word is not empty | ||
words[i] = words[i].slice(0, -1) + words[i].charAt(words[i].length - 1).toUpperCase(); | ||
} | ||
} | ||
|
||
// now we will Join the words back into a string | ||
return words.join(' '); | ||
} | ||
|
||
function capitalizeAndDisplay() { | ||
let inputText = document.getElementById("inputText").value; | ||
let capitalizedText = capitalizeLastLetterOfEachWord(inputText); | ||
document.getElementById("output").innerText = capitalizedText; | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
|
||
<h2>Capitalize Last Letter of Each Word</h2> | ||
|
||
<input type="text" id="inputText" placeholder="Enter a sentence"> | ||
<button onclick="capitalizeAndDisplay()">Capitalize</button> | ||
<div id="output"></div> | ||
|
||
</body> </html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Simple Calculator</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f0f0f0; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
h2 { | ||
text-align: center; | ||
color: #333; | ||
} | ||
.calculator { | ||
width: 300px; | ||
margin: 20px auto; | ||
padding: 10px; | ||
background-color: #fff; | ||
border-radius: 8px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
} | ||
#display { | ||
width: 100%; | ||
margin-bottom: 10px; | ||
padding: 3.5px; | ||
font-size: 20px; | ||
text-align: right; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
margin-right: 30px; | ||
} | ||
.btn-container { | ||
display: grid; | ||
grid-template-columns: repeat(4, 1fr); | ||
grid-gap: 5px; | ||
} | ||
input[type="button"] { | ||
padding: 10px; | ||
font-size: 20px; | ||
background-color: #4CAF50; | ||
color: white; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
input[type="button"]:hover { | ||
background-color: #45a049; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<h2>Simple Calculator</h2> | ||
|
||
<div class="calculator"> | ||
<input type="text" id="display" disabled> | ||
<div class="btn-container"> | ||
<input type="button" value="1" onclick="appendToDisplay('1')"> | ||
<input type="button" value="2" onclick="appendToDisplay('2')"> | ||
<input type="button" value="3" onclick="appendToDisplay('3')"> | ||
<input type="button" value="+" onclick="appendToDisplay('+')"> | ||
<input type="button" value="4" onclick="appendToDisplay('4')"> | ||
<input type="button" value="5" onclick="appendToDisplay('5')"> | ||
<input type="button" value="6" onclick="appendToDisplay('6')"> | ||
<input type="button" value="-" onclick="appendToDisplay('-')"> | ||
<input type="button" value="7" onclick="appendToDisplay('7')"> | ||
<input type="button" value="8" onclick="appendToDisplay('8')"> | ||
<input type="button" value="9" onclick="appendToDisplay('9')"> | ||
<input type="button" value="*" onclick="appendToDisplay('*')"> | ||
<input type="button" value="C" onclick="clearDisplay()"> | ||
<input type="button" value="0" onclick="appendToDisplay('0')"> | ||
<input type="button" value="=" onclick="calculate()"> | ||
<input type="button" value="/" onclick="appendToDisplay('/')"> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
function appendToDisplay(value) { | ||
document.getElementById('display').value += value; | ||
} | ||
|
||
function clearDisplay() { | ||
document.getElementById('display').value = ''; | ||
} | ||
|
||
function calculate() { | ||
let expression = document.getElementById('display').value; | ||
let result = eval(expression); /*built in JS func */ | ||
document.getElementById('display').value = result; | ||
} | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Smallest Word Finder</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f0f0f0; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
#container { | ||
width: 80%; | ||
margin: 50px auto; | ||
text-align: center; | ||
} | ||
input[type="text"] { | ||
width: 100%; | ||
padding: 10px; | ||
margin-bottom: 10px; | ||
box-sizing: border-box; | ||
} | ||
button { | ||
padding: 10px 20px; | ||
font-size: 16px; | ||
background-color: #4CAF50; | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
button:hover { | ||
background-color: #45a049; | ||
} | ||
#result { | ||
margin-top: 20px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<div id="container"> | ||
<h2>Smallest Word Finder</h2> | ||
<input type="text" id="inputString" placeholder="Enter your sentence here"> | ||
<button type="button" onclick="findSmallestWord()">Find Smallest Word</button> | ||
<p id="result"></p> | ||
</div> | ||
|
||
<script> | ||
function findSmallestWord() { | ||
const inputString = document.getElementById("inputString").value.trim(); | ||
|
||
if (!inputString) { | ||
alert("Please enter a sentence."); | ||
return; | ||
} | ||
|
||
const words = inputString.split(" "); | ||
|
||
let smallestWord = words[0]; // Initialize with the first word | ||
let smallestWordLength = smallestWord.length; | ||
|
||
for (const word of words) { | ||
if (word.length < smallestWordLength) { | ||
smallestWord = word; | ||
smallestWordLength = word.length; | ||
} | ||
} | ||
const resultElement = document.getElementById("result"); | ||
resultElement.textContent = `The smallest word is: "${smallestWord}"`; | ||
} | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.