From 20c16587646075ea0e9bad486974c880a8290365 Mon Sep 17 00:00:00 2001
From: JFarenci <31667933+JFarenci@users.noreply.github.com>
Date: Wed, 20 Dec 2017 12:15:02 -0600
Subject: [PATCH 1/4] Update scripts.js
---
scripts.js | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/scripts.js b/scripts.js
index bbbb844..4df65e6 100644
--- a/scripts.js
+++ b/scripts.js
@@ -1,8 +1,15 @@
// FILL IN THE FUNCTIONS BELOW
var sprintFunctions = {
- largestEl: function(){
- // your code here
+ largestEl: function(array){
+var highest = array[0];
+for (i = 1; i < array.lenght; i++) {
+ if (highest < array[i]) {
+ highest = array[i];
+ }
+}
+return highest;
+
},
reversed: function(){
@@ -29,4 +36,4 @@ var sprintFunctions = {
primes: function(){
// your code here
},
-}
\ No newline at end of file
+}
From 2a1eda578e6aea7e91ee2b9bf8bebc9e198dac10 Mon Sep 17 00:00:00 2001
From: JFarenci <31667933+JFarenci@users.noreply.github.com>
Date: Sun, 24 Dec 2017 14:11:24 -0600
Subject: [PATCH 2/4] Update scripts.js
---
scripts.js | 278 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 255 insertions(+), 23 deletions(-)
diff --git a/scripts.js b/scripts.js
index 4df65e6..1a1183d 100644
--- a/scripts.js
+++ b/scripts.js
@@ -1,39 +1,271 @@
// FILL IN THE FUNCTIONS BELOW
var sprintFunctions = {
- largestEl: function(array){
-var highest = array[0];
-for (i = 1; i < array.lenght; i++) {
- if (highest < array[i]) {
- highest = array[i];
- }
-}
-return highest;
-
+ largestEl: function(array){
+ var highest = array[0];
+ for (i = 1; i < array.length; i++) {
+ if (highest < array[i]) {
+ highest = array[i];
+ }
+ }
+ return highest;
},
-
- reversed: function(){
- // your code here
+
+ reversed: function(string){
+ var gnirts = String();
+ for (i = string.length -1; i >= 0; i--) {
+ gnirts += string.charAt(i);
+ }
+ return gnirts;
},
- loudSnakeCase: function(){
- // your code here
+ loudSnakeCase: function(string){
+ // really dirty code, really shouldn't do this
+ var lsc = String ();
+ var capitalize = true;
+
+ for (i = 0; i < string.length; i++) {
+ if (string.charAt(i) === " ") {
+ if (capitalize !== true){
+ lsc += "_";
+ capitalize = true;
+ }
+ }
+ else if (string.charAt(i) === "." || string.charAt(i) === "!") {
+
+ }
+ else {
+ if (capitalize === true) {
+ lsc += string.charAt(i).toUpperCase();
+ }
+ else {
+ lsc += string.charAt(i);
+ }
+ capitalize = false;
+ }
+ }
+ return lsc;
},
- compareArrays: function(){
- // your code here (replace the return)
- return "Finish compareArrays first!"
+ compareArrays: function(array1, array2){
+ var same = true;
+ for (i = 0; i < array1.length; i++) {
+ if (array1[i] !== array2[i]) {
+ same = false;
+ break;
+ }
+ }
+ return same;
},
- fizzBuzz: function(){
- // your code here
+ fizzBuzz: function(num){
+ string = [1];
+ for (i = 2; i<= num; i++) {
+ if (i % 3 === 0 && i % 5 === 0) {
+ string[(i - 1)] = "FIZZBUZZ";
+ }
+ else if (i % 3 === 0) {
+ string[(i - 1)] = "FIZZ";
+ }
+ else if (i % 5 === 0) {
+ string[(i - 1)] = "BUZZ";
+ }
+ else {
+ string[(i - 1)] = i;
+ }
+ }
+ return string;
},
- myMap: function(){
- // your code here
+ myMap: function(array){
+ var newArray = [];
+ for (i = 0; i < array.length; i++) {
+ newArray[i] = (array[i] * 2);
+ }
+ return newArray
},
- primes: function(){
- // your code here
+ primes: function(number){
+ var string = [];
+ for (i = 2; i < number; i++) {
+ var factors = 0;
+
+ for (e = 1; e <= i; e++) {
+ if (i % e === 0) {
+ factors++;
+ }
+ }
+
+ if (factors === 2) {
+ string.push(i);
+ }
+ }
+ return string;
},
+
+}
+
+
+var player = {
+funds: 100,
+boughtIn: 0,
+bet: 0
+}
+
+//Roulette Game
+alert("In this game you will be able to place bets on a roulette wheel. We have taken the courtesy of giving you a starting bank roll of $100.")
+
+while (true) {
+
+//Ask the player if they want to add to their bank roll and record these for later.
+if (confirm("Would you like to add to you bank roll?") === true) {
+while (true) {
+ var buyIn = parseInt(prompt("How much would you like to add to your bankroll?", "0"));
+
+ if (buyIn >= 0) {
+ player.funds += buyIn;
+ player.boughtIn += buyIn;
+ break;
+ }
+
+ else {
+ alert("Please input a valid number.");
+ }
+}
+}
+
+//Ask the player for how much they are going to bet.
+while (true) {
+player.bet = 0;
+player.bet = parseInt(prompt("You have $" + player.funds + " How much would you like to bet this round?", "10"));
+
+if (player.bet > player.funds) {
+ alert("You can't bet more than you have!");
+}
+
+else if (player.bet > 0) {
+ if (confirm("So you will bet $" + player.bet + " of your $" + player.funds + "?") === true) {
+ player.funds -= player.bet;
+ break;
+ }
+}
+
+else {
+ alert("Please input a valid amount to bet.");
+}
+}
+
+//Spin the wheel.
+var spin = Math.floor((Math.random() * 37.999));
+
+//Ask the player to choose a type of bet and check if it was a win or not. Uses for loop instead of switch so breaks will effect the parent while loop.
+while (true) {
+var winMult = 0;
+var typeOfBet = parseInt(prompt("Enter the corresponding number for the type of bet you want to place:\n[1] - Bet on 0, (35:1)\n[2] - Bet on 00, (35:1)\n[3] - Bet on evens, (2:1)\n[4] - Bet on odds, (2:1)\n[5] - Bet on 1-18, (2:1)\n[6] - Bet on 19-36, (2:1)\n[7] - Bet on 1-12, (3:1)\n[8] - Bet on 13-24, (3:1)\n[9] - Bet on 25-36, (3:1)"));
+
+//0
+if (typeOfBet === 1) {
+ if (spin === 0) {
+ winMult = 35;
+ }
+ break;
+}
+//00 (37)
+else if (typeOfBet === 2) {
+ if (spin === 37) {
+ winMult = 35;
+ }
+ break;
+}
+//even
+else if (typeOfBet === 3) {
+ if ((spin % 2) === 0 && 0 <= spin <= 36) {
+ winMult = 2;
+ }
+ break;
+}
+//odd
+else if (typeOfBet === 4) {
+ if ((spin % 2) === 1 && 0 <= spin <= 36) {
+ winMult = 2;
+ }
+ break;
+}
+//1-18
+else if (typeOfBet === 5) {
+ if (1 <= spin <= 18) {
+ winMult = 2;
+ }
+ break;
+}
+//19-36
+else if (typeOfBet === 6) {
+ if (19 <= spin <= 36) {
+ winMult = 2;
+ }
+ break;
+}
+//1-12
+else if (typeOfBet === 7) {
+ if (1 <= spin <= 12) {
+ winMult = 3;
+ }
+ break;
+}
+//13-24
+else if (typeOfBet === 8) {
+ if (13 <= spin <= 24) {
+ winMult = 3;
+ }
+ break;
+}
+//25-36
+else if (typeOfBet === 9) {
+ if (25 <= spin <= 36) {
+ winMult = 3;
+ }
+ break;
+}
+//invalid
+else {
+ alert("Please input a valid key response.");
+}
+}
+
+//Apply the effect of a win/loss to the player.
+player.funds += (winMult * player.bet);
+
+//Convert 37 into 00 for the display, if the player won the winMult will always be greater than 0.
+if (spin === 37) {
+if (winMult > 0) {
+ alert("The roulette spun a 00 you won! You add $" + (winMult * player.bet) + " bringing you up to $" + player.funds + ".");
+}
+else {
+ alert("The roulette spun a 00 darn, a miss. You have $" + player.funds + " left to play with.");
+}
+}
+else {
+if (winMult > 0) {
+ alert("The roulette spun a " + spin + " you won! You add $" + (winMult * player.bet) + " bringing you up to $" + player.funds + ".");
+}
+else {
+ alert("The roulette spun a " + spin + " darn, a miss. You have $" + player.funds + " left to play with.");
+}
+}
+
+//Ask if they want to play again, this controls the while loop the game resides within.
+if (confirm("Would you like to spin again?") === false) {
+break;
+}
+}
+
+//Display how the player did in the end.
+if ((player.funds - player.boughtIn) - 100 > 0) {
+alert("Over the course of your run you made $" + ((player.funds - player.boughtIn) - 100) + ".\nCongratulations!");
+}
+else if ((player.funds - player.boughtIn) - 100 < 0) {
+alert("Over the course of your run you lost $" + -1*((player.funds - player.boughtIn) - 100) + ".\nBetter luck next time.");
+}
+else {
+alert("Looks like you broke even this time, huh.");
}
From 669a4253fa1bcfe425cc11e48b809d2ebcef79f2 Mon Sep 17 00:00:00 2001
From: JFarenci <31667933+JFarenci@users.noreply.github.com>
Date: Sun, 24 Dec 2017 14:11:58 -0600
Subject: [PATCH 3/4] Update README.md
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 4f9c999..278b263 100644
--- a/README.md
+++ b/README.md
@@ -2,3 +2,4 @@ assignment_js_sprint
====================
while(1){ go() };
+Jacob Farenci
From 1fff6234a69c5f4cb3e8ea4e94b5ad120bc8f8c7 Mon Sep 17 00:00:00 2001
From: JFarenci <31667933+JFarenci@users.noreply.github.com>
Date: Thu, 11 Jan 2018 02:14:30 -0600
Subject: [PATCH 4/4] Add files via upload
---
README.md | 7 ++-
document.ready.js | 35 ++++++++++++++
index.html | 117 ++++++++++++++++++++--------------------------
jquery-3.2.1.js | 4 ++
styles.css | 44 +++++++++++++++++
5 files changed, 137 insertions(+), 70 deletions(-)
create mode 100644 document.ready.js
create mode 100644 jquery-3.2.1.js
create mode 100644 styles.css
diff --git a/README.md b/README.md
index 278b263..cd188e3 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
-assignment_js_sprint
-====================
+assignment_jq_dom_sprint
+========================
-while(1){ go() };
-Jacob Farenci
+...that DOM, D-DOM DOM DOOOOM...
diff --git a/document.ready.js b/document.ready.js
new file mode 100644
index 0000000..39ce1a6
--- /dev/null
+++ b/document.ready.js
@@ -0,0 +1,35 @@
+$(document).ready(function(){
+
+//Set H1 text to "Something Cheeky"
+$('h1').text("Something Cheeky");
+
+//Insert an HTML element to our div element with the class info-box
+$('div.info-box').append("
one
two
three
");
+
+//Change the class of "sad" elements to "happy"
+$('.sad').addClass("happy");
+$('.happy').removeClass("sad");
+
+//Change the attribute of the pop up's href link to a different url
+$('#annoying-popup a').attr('href', 'http://www.cashcats.biz');
+
+//Change the position of the pop-up with CSS styling
+$('#annoying-popup').css({
+ 'right': '0px',
+ 'top': '30px'
+});
+
+//Set our $list variable as our list we want so we can refer to it's cells
+var $list = $('.suggested-topics ul').children();
+//check each cell's inner HTML and then change it if it is "..."
+for ( i = 0; i < $list.length; i++ ) {
+ if( $list[i].innerHTML == "..." ) {
+ $list[i].innerHTML = "sample text";
+ }}
+
+//Add in a textarea and remove the text input
+$('.input-form input[type="text"]').remove();
+$('.input-form').html("" + $('.input-form').html());
+
+
+});
diff --git a/index.html b/index.html
index 2aa3713..c28ffa3 100644
--- a/index.html
+++ b/index.html
@@ -1,75 +1,60 @@
+
-
-
-
-
-
-
-
-
- Javascript Sprint Test Suite
+
+
+
+
+
+
+
+
+
+ Traverse and Manipulate
+
+ Admirable objectives for a jQuery Padwan
+
+
-
- Largest Element:
-
-
- Pending...
-
+
+
+ Upcoming traversals:
+
+
-
- Reversed String:
-
-
- Pending...
+
+
+ Input your Story
+
+
+
-
-
- Loud Snake Case:
-
-
- Pending...
+
+
+ Suggested Topics
+
+
+
Funny functions
+
Terrible traversals
+
Cogent collisions
+
Super selections
+
Massive manipulations
+
Admirable alterations
+
...
+
Killer klicks
+
+
-
- Compare Arrays:
-
-
- Note: The rest of the test suite depends on getting this right!
-