diff --git a/array.js b/array.js new file mode 100644 index 0000000..3617f26 --- /dev/null +++ b/array.js @@ -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] + "
"); + console.log(array[i]); + console.log(typeof(array[i])); + } + document.getElementById("jsOutput").innerHTML += ("JavaScript is an absolutely bizarre language."); + clickCount(); + } diff --git a/index.html b/index.html index 3cfeb45..d1215d0 100644 --- a/index.html +++ b/index.html @@ -30,49 +30,90 @@

About meCaleb

Hi! My name is Caleb Fontenot. I am a software developer in my second semester at South Lousiana Community College.

- + document.getElementById("jsOutput").innerHTML = startEnd + "
"; + document.getElementById("jsOutput").innerHTML += "*" + "
"; + document.getElementById("jsOutput").innerHTML += "* " + input + " *"+ "
"; + document.getElementById("jsOutput").innerHTML += "*" + "
"; + document.getElementById("jsOutput").innerHTML += startEnd; - + } + 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 += "
"; + } + } + 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 += " "; + } + } + } + } + document.getElementById("jsOutput").innerHTML += "
"; + } + document.getElementById("jsOutput").innerHTML += "* " + input + " *
"; + 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 += " "; + } + } + } + } + document.getElementById("jsOutput").innerHTML += "
"; + } + } + +

Pick a design!

+ + + +

diff --git a/root.css b/root.css index 584d428..6a974d9 100644 --- a/root.css +++ b/root.css @@ -35,7 +35,12 @@ body { } - +#jsOutput { + font-family: monospace; + width: 30% + text-align: start; + //margin-left: 50%; +} nav { background-color: #333333; border-style: inset;