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
14 changes: 14 additions & 0 deletions KiahHickson/week_01/MTA/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="js/mta.js"></script>

</head>
<body>

<h2>Please open the console to see the output</h2>

</body>

</html>
81 changes: 81 additions & 0 deletions KiahHickson/week_01/MTA/js/mta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// prompt()
// console.log( 'You must travel through the following stops on the N line: 34th, 28th, 23rd, Union Square.' )
// console.log( 'Change at Union Square' )
// console.log( 'Your journey continues through the following stops: 23rd, 28th, 33rd.' )
// console.log( '7 stops in total.' )

// THERE ARE ONLY THREE TYPES OF TRIPS

// Trips going forward on one line - from N line Times Square to N line Union Square
// Trips going backward on one line - from N line Union Square to N line Times Square
// Trips going between lines (remembering that we can only change at union square).
// In the case of going from N Line Times Square to 6 Line Grand Central. This is two trips
// N line Times Square to N Line Union Square
// 6 Line Union Square to 6 Line Grand Central




// STEPS:
// I only care about going forward on one line
// Let's make a for loop
// it prints out each station name from Times Square to 8th on the N Line

// Let's find out where to start in the loop and where to end
// Called indexOf



var lines = {
N: ['Times Square', '34th', '28th', '23rd', 'Union Square', '8th'],
L: ['8th', '6th', 'Union Square', '3rd', '1st'],
'6': ['Grand Central', '33rd', '28th', '23rd', 'Union Square', 'Astor Place']
}

var planTrip = function(startLine, startStop, endLine, endStop) {
// console.log("Start" startLine, startStop, endLine, endStop)

// Print out the whole array associated with the startLine
console.log( "startLine: ", startLine );
var startingLineStops = lines[ startLine ];
console.log( "startingLineStops: ", startingLineStops );

var startIndex = startingLineStops.indexOf( startStop );
var endIndex = startingLineStops.indexOf( endStop) + 1;

// THIS IS WHERE THE FOR LOOP GOES
for (var i = startIndex; i < endIndex; i++) {
var stationName = startingLineStops[i];
console.log( stationName );
// [i].startingLine
};

// What if I want to go backwards
// Use the indexOf
// Decide whether the start stop is earlier in the array than the end stop
// If it is, do the same for loop that we have
// If it's not, do the opposite. Do a loop that goes down
// Print out the whole array associated with the endLine
// console.log("endLine:", endLine );
// var endLine = lines [ endLine ];
// console.log( endLine );

var planReturnTrip = function(endLine, startStop, startLine, endStop) {

console.log( "endLine: ", endLine );
var endLineStops = lines[ endLine ];
console.log( "endLineStops: ", endLineStops );

var startIndex = endLineStops.indexOf( endStop );
var endIndex = startingLineStops.indexOf( startStop) - 1;

// THIS IS WHERE THE FOR LOOP GOES
for (var i = endIndex; i < startIndex; i--) {
var stationName = endLineStops[i];
console.log( stationName );

}

planTrip('6', 'Astor Place', '6', 'Grand Central');


33 changes: 33 additions & 0 deletions KiahHickson/week_01/MTA/js/untitled
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

// Create a program that models a simple subway system.

// The program takes the line and stop that a user is getting on at
and the line and stop that user is getting off at
and prints the journey and the total number of stops for the trip in the console:


// There are 3 subway lines:
// The N line has the following stops: Times Square, 34th, 28th, 23rd, Union Square, and 8th
// The L line has the following stops: 8th, 6th, Union Square, 3rd, and 1st
// The 6 line has the following stops: Grand Central, 33rd, 28th, 23rd, Union Square, and Astor Place.
// All 3 subway lines intersect at Union Square, but there are no other intersection points. (For example, this means the 28th stop on the N line is different than the 28th street stop on the 6 line, so you'll have to differentiate this when you name your stops in the arrays.)
// Tell the user the number of stops AND the stops IN ORDER that they will pass through or change at.
// Hints:


// planTrip('N', 'Times Square', '6', '33rd'); // This is only a suggested function name and signature.

// // console.log() shows output similar to this:
// // "Your must travel through the following stops on the N line: 34th, 28th, 23rd, Union Square."
// // "Change at Union Square."
// // "Your journey continues through the following stops: 23rd, 28th, 33rd."
// // "7 stops in total."


// Work out how you would do it on paper first! Then start to explain that process in Javascript.
// Get the program to work for a single line before trying to tackle multiple lines.
// Don't worry about prompting the user for input. Hard code some values to get it working. You can use prompt() later to make it more interactive.
// Consider diagramming the lines by sketching out the subway lines and their stops and intersection.
// The key to the lab is finding the index positions of each stop. (hint: indexOf())
// Make sure the stops that are the same for different lines have different names (i.e. 23rd on the N and on the 6 need to be differentiated)

16 changes: 16 additions & 0 deletions KiahHickson/week_01/geometryFunctionLab/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="js/ex2.js"></script>


</head>
<body>

<h2>Please open the console to see the output</h2>

</body>

</html>
52 changes: 52 additions & 0 deletions KiahHickson/week_01/geometryFunctionLab/js/ex1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Geometry Function Lab
// Part 1, Rectangle

// Given the following a rectangle object like the one below, write the following functions:

// isSquare - Returns whether the rectangle is a square or not
// area - Returns the area of the rectangle
// perimeter - Returns the perimeter of the rectangle
// var rectangle = {
// length: 4,
// width: 4
// };


// I have an object, it has a length and a width property
// I need a function that give find the area of that object
// Inside that function, I need to add the length and width together and then multiply by two
// I then need to return and console.log that number




var rectangle = {
length: 4,
width: 3
}

var isSquare = function (shape) {

var square = shape.length === shape.width;

console.log('isSquare', square)
return square

}
var findArea = function (shape) {

var area = shape.length * shape.width;

console.log('findArea', area)
return area

}

var findPerimeter = function (shape) {

var perimeter = shape.length + shape.width * 2;

console.log('findPerimeter', perimeter)
return perimeter

}
76 changes: 76 additions & 0 deletions KiahHickson/week_01/geometryFunctionLab/js/ex2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Part 2, Triangle

// Given the following a triangle object like the one below, write the following functions:

// isEquilateral - Returns whether the triangle is equilateral or not
// isIsosceles - Returns whether the triangle is isosceles or not
// area - Returns the area of the Triangle
// isObtuse - Returns whether the triangle is obtuse or not
// var triangle = {
// sideA: 3,
// sideB: 4,
// sideC: 4
// };




var triangle = {
sideA: 3,
sideB: 4,
sideC: 4

}

var isEquilateral = function (shape) {

var equilateral = shape.sideA === shape.sideB && shape.sideB === shape.sideC;

console.log('isEquilateral', equilateral)
return equilateral

}


var isIsosceles = function (shape) {

if (isEquilateral(shape)) {
return false
} else if (shape.sideB === shape.sideC) {
return true;
}


var findArea = function (shape) {

var area = shape.sideA + shape.sideB / 2;

console.log('findArea', area)
return area
}


var isObtuse = function (shape) {

if (isEquilateral(shape)) {
return false
} else if (shape.sideB === shape.sideC) {
return true;
}
}
}


// var obtuse = function (sideA, sideB, sideC) {

// if (isIsocoles(triangle.sideA, triangle.sideB, triangle.sideC))==='Is Not Isocoles') {

// } &&(isEquilateral (triangle.sideA, triangle.sideB, triangle.sideC))==='Is Not Equilateral')) {
// return 'Is Obtuse'
// } else {
// return 'Is Not Obtuse'

// console.log(obtuse(triangle))

// }
// }
71 changes: 71 additions & 0 deletions KiahHickson/week_01/geometryFunctionLab/js/ex3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
var oneBank = [

{ name: "Ash", accountBal: 1000 },
{ name: "Misty", accountBal: 1900 },
{ name: "Meowth", accountBal: 200 },
{ name: "Brock ", accountBal: 1900 }

]

// There is only one bank. This bank has an array of accounts. The bank needs a method that will return the total sum of money in the accounts. It also needs an addAccount method that will enroll a new account at the bank and add it to the array of accounts. There is no need to create additional functions of the bank to delete accounts, etc.

var addAccount = function (n, b) {
var newName = n.toString();
var newBal = parseFloat(b);
oneBank.push({name: newName, accountBal: newBal});

}

// Accounts have a current balance and owner's name.

//You should be able to deposit or withdraw from an account to change the balance.



var deposit = function (a, b) {

for (var i = 0; i < oneBank.length; i++) {
if(oneBank[i].name === a) {

oneBank[i].accountBal = b + oneBank[i].accountBal

}
}
}


var withdraw = function (c, d) {

for (var i = 0; i < oneBank.length; i++) {
if(oneBank[i].name === c) {

oneBank[i].accountBal = d - oneBank[i].accountBal

}
}
}



// Bonus

// Ensure that the accounts cannot have negative values.
// Write a 'transfer' on the bank that allows you to transfer amounts between two accounts.


var transfer = function (name1, name2, cash) {

if(oneBank[i].accountBal < 0 = cash *=-1

withdraw(name1, cash)
deposit(name2, cash)


}







2 changes: 1 addition & 1 deletion KiahHickson/week_01/warmups/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="js/rainDrops.js"></script>
<script src="js/leapYear.js"></script>

</head>
<body>
Expand Down
Loading