Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Challenges/Week2/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

//create function
//control and return statements

Expand All @@ -6,3 +7,23 @@
//Call function

//Alert user results

function processInput(message)
{
if(message === "Hello!")
{
return("Hello World!");
}
else {
return("You didn't say hello :(");
}
}

var userInput;
var response;

userInput = prompt();

response = processInput(userInput);

alert(response);
2 changes: 1 addition & 1 deletion Challenges/Week2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ <h2>My first code challenge!</h2>
<li>Don't forget to call your script file from this HTML file! I've created the script tags for you, but you have to add something to it!
</ol>

<script></script>
<script src="app.js"></script>
</body>
</html>
9 changes: 7 additions & 2 deletions Challenges/Week3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ <h1>Flash Cards</h1>
</li>
</ul>

<button class="cheat-button">Show All Answers</button>
<button class="cheat-button1">Show All Answers</button>
<button class="cheat-button2">Hide All Answers</button>


<!--Replace this comment with a script tag from https://code.jquery.com/ -->
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.jquery.com/jquery-3.1.0.js" integrity="sha256-slogkvB1K3VOkzAI8QITxV3VzpOnkeNVsKvtkYLMjfk=" crossorigin="anonymous"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script></script>


</body>
</html>
25 changes: 20 additions & 5 deletions Challenges/Week3/js/app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@

// 1.) Make sure you have a reference to jQuery from a CDN in the index.html file.

// 2.) Use a jQuery to hide all of the answers to all the questions.
$('.answer')
$('.answer').hide();

/* 3.) Write code to show the answer when hovering over a flash card, and hide it when the mouse leaves.
Find the approriate event on the jQuery API page to trigger an action on hover https://api.jquery.com/category/events/
Hint: You can use "this" inside your jQuery function to reference a selected DOM node. */
$('.flash-card')

$(document).ready(function(){
$(".flash-card").mouseenter(function(){
$('.answer').show();
});
$('.flash-card').mouseout(function(){
$('.answer').hide();
});
});
/* 4.) Use jQuery to find the button element on the page and have it toggle all of the answers on and off when clicked.
Hint: jQuery has a toggle function that can toggle the visibility of a selected DOM node.
Bonus: Change the text of the button using jQuery when you toggle the answers on/off. */
$()
Bonus: Change the text of the button using jQuery when you toggle the answers on/off. */
$('.cheat-button1').click(function(){
$('.answer').show();
});
$('.cheat-button2').click(function(){
$('.answer').hide();
});



26 changes: 26 additions & 0 deletions Challenges/Week4/ChallengeFiles/challenge.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
body {
background-color: black;
padding: 10px;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
color: white;
}

.planet {
width: 300px;
height: 300px;
border-radius: 50%;
text-align: center;
padding: 10px;
position: relative;
background-color: blue;
}

.moon {
position: absolute;
width: 50px;
height: 50px;
border-radius: 50%;
background: rgb(153, 153, 153);
}

15 changes: 15 additions & 0 deletions Challenges/Week4/ChallengeFiles/challenge.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="challenge.css">

</head>

<body>

<h1>Week 4 Code Challenge: </h1>
<h2>DOM manipulation with only JavaScript!</h2>
<div class = "planet"></div>
<div class= "moon"></div>
<script src="challenge.js"></script>
</body>
</html>
8 changes: 8 additions & 0 deletions Challenges/Week4/ChallengeFiles/challenge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Part 1: Create a new div of class "planet" and set its background color
// to the color of your choice. Then, append it to the body in the DOM.
$("planet").append("<body></body>");


// Part 2: Create a new div of class "moon" and append it to the planet in the DOM.
$("moon").append("<div>planet</div>");

102 changes: 101 additions & 1 deletion Challenges/Week5/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,105 @@ function addPokemon(name) {
`).appendTo('#pokemon');
};

<<<<<<< HEAD
//Using these variables to store the url of the next and previous list of Pokémon
var prevList = null;
var nextList = null;

//This will hide the list of Pokémon and insert new html to show Pokémon detail.
function showPokemonDetail(name) {
$('.poke-card').hide();
$('#previous, #next').hide();
//$('#back').show();
var spriteUrl = null;
var pokeName = null;
var pokeType = null;

$.getJSON(`http://pokeapi.co/api/v2/pokemon/${name}`,function(data){
pokeName = data.name;
spriteUrl = data.sprites.front_default;
pokeType = data.types[0].type.name;
$(`
<div id="poke-detail">
<img src="${spriteUrl}">
<h3 class="name">${pokeName}</h3>
<p>${pokeType}</p>
<ul id="stats"></ul>
<button id="back" class="btn">Back</button>
</div>
`).appendTo('#pokemon');

data.stats.forEach(function(stat){
$(`
<li class="poke-card">
<strong>${stat.stat.name}: </strong> ${stat.base_stat}
</li>
`).appendTo('#stats');
});

});


};

function hidePokemonDetail() {
$('#poke-detail').remove();
$('.poke-card').show();

$('#previous, #next').show();
//$('#back').hide();
}


//Displays a list of Pokémon given a resource URL
function displayPokes(resource) {
$.getJSON(resource, function(data) {
prevList = data.previous;
nextList = data.next;
data.results.forEach(function(pokemon){
addPokemon(pokemon.name);
});

if(!prevList) {
$('#previous').prop("disabled", true);
} else { $('#previous').prop("disabled", false); }

if(!nextList) {
$('#next').prop("disabled", true);
} else { $('#next').prop("disabled", false); }

}).done(function(){
$('.poke-card').click(function(){
var selectedPokemon = $(this).find('h3').text();
showPokemonDetail(selectedPokemon);
});
});

}

//Register a click handler for the previous and next buttons.
$('#previous, #next').click(function(){
$('.poke-card').remove();

if(this.id === 'previous' && prevList) {
displayPokes(prevList);
}

if(this.id === 'next' && nextList) {
displayPokes(nextList);
}
});


//Using on instead of click to look for events triggered by elements created after the DOM was loaded.
$('#pokemon').on('click', '#back', function() {
hidePokemonDetail();
});


//Initial display of Pokémon
displayPokes('http://pokeapi.co/api/v2/pokemon');
=======

// 1.) Use the PokéAPI from http://pokeapi.co along with jQuery's getJSON function to retrieve the first 20 Pokémon.
// 1.1) Use the addPokemon function to show each of the Pokémon names that were retrieved.
Expand All @@ -22,4 +121,5 @@ function addPokemon(name) {
type or anything else you would like to include. Add a way to go back to the list when your're done looking at the detail.

Be creative, you can style/arrange the detail information however you like!
*/
*/
>>>>>>> 85a3bb7dd64688251fe2c8d02fe7fc33d630c149
5 changes: 3 additions & 2 deletions Challenges/Week6/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3>Extra credit</h3>
<td><span id="output"></span>
<td><button id="Print" class="btn">Print Box</button></td>
</tr>
<tr>
<tr/>
<td>Height:</td>
<td><button id="HeightDecrease" class="btn">-</button></td>
<td><button id="HeightIncrease" class="btn">+</button></td>
Expand All @@ -46,6 +46,7 @@ <h3>Extra credit</h3>

<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>

<span output="Height:HeightDecrease"></span>
<span output="Height:HeightIncrease"></span>
</body>
</html>
36 changes: 34 additions & 2 deletions Challenges/Week6/js/app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
//#Week 6 JQuery Code Challenge


//Objects

var boxy = function(h, w){
this.height = h;
this.width = w;
};
boxy.prototype.area = function(h = this.height,w = this.width){
return h * w;
}:
boxy.prototype.areaIncrease: function(){
this.height ++;
this.width ++;
};
boxy.prototype.areaDecrease: function(){
this.height --;
this.width --;
};

boxy.prototype.heightIncrease: function(){
this.height ++;
};
boxy.prototype.widthIncrease: function(){
this.width ++;
};
boxy.prototype.heightDecrease: function(){
this.height --;
};
boxy.prototype.widthDecrease: function(){
this.width --;
};


//Code Challenge:
//Create an object named "Box" with 3 properties, height, width, volume.
//Create an object named "Box" with 3 properties, height, width, volume

//Create 2 buttons for Height. The first button decreases the Box Height by 1. The second button increases the Box Height by 1.

//Create a button that prints the object and its attributes to the page (use the span "output".

//Extra credit
Expand Down