Skip to content

Instantly share code, notes, and snippets.

View Lysdora's full-sized avatar
🏠
Working from home

murloc-craft Lysdora

🏠
Working from home
View GitHub Profile
@Lysdora
Lysdora / countdown.js
Created November 17, 2017 11:49
CodeSchool countdown.js
/*
A Basic Conditional
In countdown.js, modify the while loop with a conditional that will only allow a number to be printed if it is even. Your results should be the even numbers from 10 to 2 in descending order. Think carefully about how your code might decide if a number is even…
*/
var num = 10;
while (num > 0) {
if (num % 2 === 0){
console.log(num);
@Lysdora
Lysdora / hooverDam.js
Created November 17, 2017 11:07
CodeSchool These Dam Loops
/*
These Dam Loops!
The Hoover Dam has 19 generators of multiple types. For simplicity, let’s say that the first 4 of these generators output 62 megawatts, and the other 15 output 124 megawatts. In hooverDam.js, the Dam Rangers have asked you to design a system of two loops that turns each generator on in progression, and prints the new total of megawatts generated.
They’d like the first loop to be a while loop handling the first 4 generators. Then, they’d like the second loop to be a for loop that handles the other 15 generators. Each output line should resemble the following lines, with adjusted values for the currentGen and totalMW:
Generator #1 is on, adding 62 MW, for a total of 62 MW!
Generator #2 is on, adding 62 MW, for a total of 124 MW!
We’ve given you some starting variables to use in your build.
*/
var currentGen = 1;
@Lysdora
Lysdora / sheep.js
Created November 17, 2017 10:33
CodeShool
/*
Morph your previous while loop into a for loop that uses the same variable names. Remember, you’ll still need to declare the starting number of sheep and the number of months to print outside the loop. We’ve given you the starting number of sheep again, as well as the amount of months you’ll need to print out for use in the loop parameters. Here’s a solution for the previous while loop for reference:
var numSheep = 4;
var monthNumber = 1;
var monthsToPrint = 12;
while (monthNumber <= monthsToPrint) {
numSheep = numSheep * 4;
console.log("There will be " + numSheep + " sheep after " + monthNumber + " month(s)!");
monthNumber++;
@Lysdora
Lysdora / trainNumber.js
Created November 17, 2017 10:32
CodeSchool
/* Code Shool Learn JS */
// LOOPS
// V1 with while
var trainNumber = 1;
while (trainNumber <= 8) {
console.log("Train #" + trainNumber + " is running.");
trainNumber++;
}
/* For Loops Problem Set */
console.log("Print all numbers between -10 and 19");
for (var i = -10; i <= 19; i++) {
console.log(i);
}
console.log("Print all even numbers between 10 and 40");
@Lysdora
Lysdora / annoy.js
Created November 17, 2017 07:40
Anny Omatic Loop
/* Anny-omatic */
/*
// V1
while (answer !== "yes" && answer !== "yeah" &&) {
var answer = prompt("Are we there yet?");
}
alert("Yay, we made it !");*/
@Lysdora
Lysdora / javaScript_ex.js
Created November 17, 2017 07:08
The Web Developper Bootcamp [1]
// while loops
// Print all numbers between -10 and 19
var x = -10;
while (x <= 19) {
console.log(x);
x++;
@Lysdora
Lysdora / guessingGame.js
Created November 17, 2017 07:06
Simple Guessing Game
/* Simple Guessing Game */
// Create secretNumber
var secretNumber = 4;
// ask user for guess
var guess = Number(prompt("Guess a number"));
//check guess is right
if (guess=== secretNumber) {