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 / 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) {
@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 / 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 !");*/
/* 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 / 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++;
}
@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 / 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 / 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 / deathValley.js
Created November 17, 2017 12:24
CodeShool
/*
Problem Solving with Conditionals
Back at Death Valley, scientists could see that the Sheep Situation would quickly get out of control. They have decided that, for any month the population climbs above 10000, half of the sheep will be sent away to other regions.
Inside our for loop, insert an if statement that:
Removes half of the sheep population if the number of sheep rises above 10000.
Prints the number of sheep being removed to the console in the following format:
Removing <number> sheep from the population.
Note: To complete the challenge, you only need to insert the if statement. You do not need to create an else statement or change any of the provided code.
*/
@Lysdora
Lysdora / hooverDam2.js
Created November 17, 2017 15:42
codeschool challenge 8
/*
Some Dam Complex Conditionals!
The people at the Hoover Dam have called you back, and would like a program that shows what happens when only the even numbered turbines are turned on. And they want it all in just one for loop.
With a set of complex conditional statements inside the loop, construct a way to only turn on even numbered turbines. Remember our power output situation:
Generators 1 through 4 produce 62 MW.
Generators 5 through 19 produce 124 MW.