Skip to content

Instantly share code, notes, and snippets.

View darinthompson's full-sized avatar

Darin Thompson darinthompson

  • Coeur d'Alene, Idaho
View GitHub Profile
@darinthompson
darinthompson / Program.cs
Created July 6, 2018 20:17
Probability game
using System;
namespace headsOrTails
{
class Program
{
static void Main(string[] args)
{
Random rand = new Random();
int numberOfGames = 1;
Cat Pics - https://jsbin.com/zerado/1/edit?html,css,js,output
FizzBuzz - https://jsbin.com/kezarir/2/edit?html,css,js,output
Lightbulb - https://jsbin.com/casevex/3/edit?html,css,js,output
most frequent word - https://jsbin.com/wipuwez/3/edit?js,console
object recipe - https://jsbin.com/sahujas/edit?js,console
merged data streams - https://jsbin.com/feqifuk/8/edit?html,js,output
Here are the links to the objects basics answers.
- Key Deleter https://jsbin.com/powifo/2/edit?js,console
- Self Reference https://jsbin.com/hohuzid/2/edit?js,console
- Object Creator https://jsbin.com/honawe/1/edit?js,console
- Object Updater https://jsbin.com/bavuciw/2/edit?js,console
* What is scope? Your explanation should include the idea of global vs. local scope.
- Simply put scope is where and how a variable is available in your code. There are two types Global and local.
Global variables are available anywhere in your code and are easy to accidentally change later on in your code, so they should be avoided.
Local scope or local variables only exist in the context in which they are defined such as a variable inside a function.
* Why are global variables avoided?
- Global variables are often avoided because they can lead to unintended side effects in your program or easily be overwritten\
later on in the program.
* Explain JavaScript's strict mode
fizzBuzz link: https://jsbin.com/jazihu/1/edit?js,console,output
array average link: https://jsbin.com/nusiga/2/edit?js,console
min and max link: https://jsbin.com/topugu/edit?js,console
// STOPLIGHT
function doTrafficLights() {
var activeLight = getActiveLight();
// your code will replace this call
// to `console.log()`
if (activeLight == "red") {
turnRed();
} else if (activeLight == "yellow") {
turnYellow();
// SQUARE AREA
function computeArea(width, height) {
// your code here
return width * height;
}
/* From here down, you are not expected to
understand.... for now :)
// WISEPERSON GENERATOR
function wisePerson(wiseType, whatToSay) {
// your code here
var phrase = 'A wise ' + wiseType + ' once said: "' +
whatToSay + '".'
return phrase;
}
/* From here down, you are not expected to
@darinthompson
darinthompson / perdiem.rb
Created January 25, 2016 03:36
adding functionality to script. Wondering why it repeats the gets.chomp and gives weird answer.
require 'date'
class PerDiem
attr_accessor :start_date, :end_date,
def initalize(start_date, end_date, per_diem)
@start_date = start_date