Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
dmd-3475/week-5/index.html
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
76 lines (76 sloc)
2.14 KB
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Chapter 3 Exercises</title> | |
</head> | |
<body> | |
<div class="minimum"> | |
<h1>Minimum Function</h1> | |
<pre> | |
<code> | |
function min(num1, num2) { | |
return num1 < num2 ? num1 : num2 | |
} | |
</code> | |
</pre> | |
<input type="number" name="num1" id="num1" value="0"> | |
<input type="number" name="num2" id="num2" value="0"> | |
<div>Minimum: <span id="minOutput"></span></div> | |
</div> | |
<div class="recursion"> | |
<h1>Recursion</h1> | |
<pre> | |
<code> | |
function isEven(num) { | |
num < 0 ? num *= -1 : num | |
if (num == 0) return true | |
else if (num == 1) return false | |
else return isEven(num - 2) | |
} | |
</code> | |
</pre> | |
<input type="number" name="recursion" id="isEven" value="0"> | |
<div>Is Even?: <span id="evenOutput"></span></div> | |
</div> | |
<div class="bean"> | |
<h1>Bean Counting</h1> | |
<pre> | |
<code> | |
function countBs(beanString) { | |
let count = 0 | |
for (let i = 0; i < beanString.length; i++) { | |
const element = beanString[i]; | |
if (element === 'B') count++; | |
} | |
return count | |
} | |
</code> | |
</pre> | |
<input type="text" name="bean" id="beanInput" placeholder="String to search"> | |
<div><span id="beanOutput"></span> B's</div> | |
</div> | |
<div class="char"> | |
<h1>Char Counting</h1> | |
<pre> | |
<code> | |
function countChar(string, char) { | |
let count = 0; | |
for (let i = 0; i < string.length; i++) { | |
const element = string[i]; | |
if (element === char) count++; | |
} | |
return count; | |
} | |
</code> | |
</pre> | |
<input type="text" name="charInput" id="charInput" placeholder="String to search"> | |
<input type="text" name="inputChar" id="inputChar" placeholder="Character to look for" maxlength="1"> | |
<div><span id="charOutput"></span> <span id="charSearch"></span>'s</div> | |
</div> | |
<script src="minimum.js"></script> | |
<script src="recursion.js"></script> | |
<script src="bean.js"></script> | |
</body> | |
</html> |