master
Caleb Fontenot 2023-03-22 17:56:20 +07:00
parent 28e959c218
commit d2d5fa9361
3 changed files with 127 additions and 42 deletions

@ -0,0 +1,39 @@
var timesClicked = 0;
function clickCount() {
timesClicked++;
if (timesClicked == 1) {
document.getElementById("theButton").innerHTML = "You've clicked me 1 time.";
} else {
document.getElementById("theButton").innerHTML = "You've clicked me " + timesClicked + " times.";
}
}
function main() {
// Clear output paragraph
document.getElementById("jsOutput").innerHTML = "";
var array = new Array(10);
for (let i = 0; i < array.length; ++i) {
let temp = parseInt(Math.random() * 100) + " array index: " + i;
array[i] = temp;
console.log(i);
}
for (let i = 0; i < array.length; ++i) {
for (let j = 1; j < array.length; ++j) {
let compare1 = array[i].slice(0, array[i].indexOf(" "));
let compare2 = array[j].slice(0, array[j].indexOf(" "));
console.log(compare1 + " " + compare2);
if (compare1 >= compare2) {
array[i] = array.splice(j, 1, array[i])[0];
}
}
}
for (let i = 0; i < array.length; ++i) {
document.getElementById("jsOutput").innerHTML += (array[i] + "</br>");
console.log(array[i]);
console.log(typeof(array[i]));
}
document.getElementById("jsOutput").innerHTML += ("JavaScript is an absolutely bizarre language.");
clickCount();
}

@ -30,49 +30,90 @@
<h2 class="aboutme">About me<img class="aboutme" src="Caleb.jpg" alt="Caleb" height="5%" width="5%"></h2>
<p>Hi! My name is <mark>Caleb Fontenot.</mark> I am a software developer in my second semester at South Lousiana Community College.</p>
<script type="text/javascript">
var timesClicked = 0;
function clickCount() {
timesClicked++;
if (timesClicked == 1) {
document.getElementById("theButton").innerHTML = "You've clicked me 1 time.";
} else {
document.getElementById("theButton").innerHTML = "You've clicked me " + timesClicked + " times.";
<script>
function design1() {
var input = prompt("Enter a greeting.");
var startEnd = "";
for (let i = 0; i < input.length + 2; i++) {
startEnd += "*";
}
}
function main() {
// Clear output paragraph
document.getElementById("jsOutput").innerHTML = "";
var array = new Array(10);
for (let i = 0; i < array.length; ++i) {
let temp = parseInt(Math.random() * 100) + " array index: " + i;
array[i] = temp;
console.log(i);
}
for (let i = 0; i < array.length; ++i) {
for (let j = 1; j < array.length; ++j) {
let compare1 = array[i].slice(0, array[i].indexOf(" "));
let compare2 = array[j].slice(0, array[j].indexOf(" "));
console.log(compare1 + " " + compare2);
if (compare1 >= compare2) {
array[i] = array.splice(j, 1, array[i])[0];
}
}
}
for (let i = 0; i < array.length; ++i) {
document.getElementById("jsOutput").innerHTML += (array[i] + "</br>");
console.log(array[i]);
console.log(typeof(array[i]));
}
document.getElementById("jsOutput").innerHTML += ("JavaScript is an absolutely bizarre language.");
clickCount();
}
</script>
document.getElementById("jsOutput").innerHTML = startEnd + "<br>";
document.getElementById("jsOutput").innerHTML += "*" + "<br>";
document.getElementById("jsOutput").innerHTML += "* " + input + " *"+ "<br>";
document.getElementById("jsOutput").innerHTML += "*" + "<br>";
document.getElementById("jsOutput").innerHTML += startEnd;
<button id="theButton" class=button onclick="main()">Click me!</button>
}
function design2() {
var input = prompt("Enter a greeting.");
var height = (input.length * 2) + 6;
var mid = Math.trunc(height / 2) + 1;
if (height % 2 == 0) {
height++;
}
document.getElementById("jsOutput").innerHTML = "";
for (let i = 0; i < height; i++) {
if (mid == i) { //Determine if we're in the middle of the triangle
document.getElementById("jsOutput").innerHTML += "**" + input + "**";
} else {
for (let j = 0; j < i; j++) {
document.getElementById("jsOutput").innerHTML += "*";
}
}
document.getElementById("jsOutput").innerHTML += "<br>";
}
}
function design3() {
var input = prompt("Enter a greeting.");
var height = (input.length * 2) + 6;
var mid = Math.trunc(height / 2) + 1;
if (height % 2 == 0) {
height++;
}
document.getElementById("jsOutput").innerHTML = "";
if (mid % 2 == 1) { // Skip a line if odd
var subOffset = 1;
var addOffset = 0;
} else {
var subOffset = 0;
var addOffset = 1;
}
for (let i = 0; i < mid - addOffset; i++) {
for (let j = 0; j < i; j++) {
if (i % 2 == 1) {
if (i != (mid - 1)) {
if (i == 0 || (j == 0 || j == (i - 1))) { // Check if we're at the beginning or end of the line
document.getElementById("jsOutput").innerHTML += "*";
} else {
document.getElementById("jsOutput").innerHTML += "&nbsp;";
}
}
}
}
document.getElementById("jsOutput").innerHTML += "<br>";
}
document.getElementById("jsOutput").innerHTML += "* " + input + " *<br>";
for (let i = mid - subOffset; i > 0; i--) {
for (let j = 0; j < i; j++) {
if (i % 2 == 1) {
if (j != (mid - 1) || (j != mid)) {
if ((i == 0 || (j == 0 || j == (i - 1)))) { // Check if we're at the beginning or end of the line
document.getElementById("jsOutput").innerHTML += "*";
} else {
document.getElementById("jsOutput").innerHTML += "&nbsp;";
}
}
}
}
document.getElementById("jsOutput").innerHTML += "<br>";
}
}
</script>
<p>Pick a design!</p>
<button id="design1" class=button onclick="design1()">Design 1</button>
<button id="design2" class=button onclick="design2()">Design 2</button>
<button id="design3" class=button onclick="design3()">Design 3</button>
<p id="jsOutput"></p>

@ -35,7 +35,12 @@ body {
}
#jsOutput {
font-family: monospace;
width: 30%
text-align: start;
//margin-left: 50%;
}
nav {
background-color: #333333;
border-style: inset;