This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var countDown = function(starter) { | |
if (starter === 0) { | |
return starter; | |
} | |
else { | |
console.log(starter); | |
return countDown(--starter); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = ""; | |
var player = prompt("Pick rock, paper, or scissors."); | |
if(player !== null){ | |
player = player.toLowerCase(); | |
} | |
var choices = ["rock","paper","scissors"]; | |
var computer = choices[Math.floor(Math.random()*3)]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//array 1: the suits | |
var suits = ["clubs","hearts","diamonds","spades"]; | |
//array 2: the ranks | |
var ranks = [2,3,4,5,6,7,8,9,10,"J","Q","K","A"]; | |
var deck = []; | |
for(i=0; i<suits.length; i++){ | |
for(j=0; j<ranks.length; j++){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FizzBuzzPlus={ | |
isFizzBuzzie: function(n){ | |
if((n%3===0 || n%5===0) && !(n%3===0 && n%5===0)){ | |
return true; | |
} else { | |
return false; | |
} | |
}, | |
getFizzBuzzSum: function(max){ | |
var sum = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(i=1; i<=20; i++){ | |
var result = i; | |
if(i%3===0){ | |
if(i%5===0){ | |
console.log("FizzBuzz"); | |
} else { | |
console.log("Fizz"); | |
} | |
} else if(i%5===0){ | |
console.log("Buzz"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var deal = function() { | |
card = Math.floor(Math.random()*52+1); | |
return card; | |
}; | |
var card1 = deal(); | |
var card2 = deal(); | |
var getValue = function(card) { | |
if(card % 13 === 0 || card % 13 > 10){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var calculateTotalCosts = function(salary,numWorkers,city){ | |
var fixedCosts = 5000; | |
var variableCosts = salary*numWorkers; | |
if(city === "NYC"){ | |
return fixedCosts+variableCosts+30000; | |
} else if(city === "BEJ"){ | |
return fixedCosts+variableCosts+25000; | |
} else { | |
return fixedCosts+variableCosts+10000; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var calculateTotalCosts = function(salary,numWorkers,city){ | |
var fixedCosts = 5000; | |
var variableCosts = salary*numWorkers; | |
if(city === "NYC"){ | |
return fixedCosts+variableCosts+30000; | |
} else { | |
return fixedCosts+variableCosts; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var die1 = Math.floor(Math.random()*6 + 1); | |
var die2 = Math.floor(Math.random()*6 + 1); | |
var score; | |
if(die1 === 1 || die2 === 1){ | |
score = 0 | |
} else { | |
if(die1 === die2){ | |
score = die1+die2*2 | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var food = prompt("What's for dinner?") | |
foodType = food === "taco" ? "Mexican" : "other"; |