Skip to content

Commit 5f09386

Browse files
committed
still working on it
1 parent b81b502 commit 5f09386

File tree

19 files changed

+156
-24
lines changed

19 files changed

+156
-24
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.DS_Store
1+
.DS_Store
2+
**/node_modules
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const input = require('readline-sync');
22

33
let name = input.question("Enter your first name: ");
4-
let otherName = input.question ("Enter your last name: ")
5-
console.log("First name:" , name)
6-
console.log("Last name:" , otherName)
7-
console.log("Last, First:" , otherName + "," , name)
4+
let otherName = input.question ("Enter your last name: ");
5+
console.log("First name:" , name);
6+
console.log("Last name:" , otherName);
7+
console.log("Last, First:" , otherName + "," , name);

functions/studio/studio-functions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@ function areaOfShape(length, width = length) {
110110
}
111111
}
112112

113-
console.log(areaOfShape(7, 7))
113+
console.log(areaOfShape(7))

functions/try-it/reverse.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@ function reverse(str) {
33
let reversedLettersArray = lettersArray.reverse();
44
return reversedLettersArray.join('');
55
}
6+
console.log(reverse('hello'));
7+
8+
let reversedLetters = function(str) {
9+
str.split('').reverse().join('');
10+
return reversedLetters;
11+
};
12+
console.log(reversedLetters('hello'));
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Experiment with this loop by modifying each of the following: the variable initialization, the boolean condition, and the update expression.
22

3-
for (let i = 0; i < 51; i++) {
3+
for (let i = 23; i < 30; i = i + 2) {
44
console.log(i);
55
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
// create an array variable containing the names
2-
2+
let family = ["Rachel", "Katie", "Gus", "Ozzie", "Roxy", "Dewey"];
33
// write a for loop that prints each name on a different line
4+
for (let i = 0; i < family.length; i++) {
5+
console.log(family[i]);
6+
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
// Create a string variable containing your name.
2+
let myName = "KATIE";
23

34

4-
// Write a for loop that prints each character in your name on a different line.
5+
// Write a for loop that prints each character in your name on a different line.
6+
7+
for (let i = 0; i < myName.length; i++) {
8+
console.log(myName[i]);
9+
}

loops/exercises/package-lock.json

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

loops/exercises/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"readline-sync": "^1.4.10"
4+
}
5+
}

loops/package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

more-on-functions/chapter-examples/receieve-function-arguments/getValidInput.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,21 @@ function getValidInput(prompt, isValid) {
1414

1515
// TODO 1: write a validator
1616
// that ensures input starts with "a"
17+
let isValidEntry1 = function(entry) {
18+
if (entry[0] !== "a") {
19+
return false;
20+
}
21+
return true;
22+
};
1723

1824
// TODO 2: write a validator
1925
// that ensures input is a vowel
20-
26+
let isValidEntry2 = function(entry) {
27+
if (entry[0] == "a" || entry[0] == "e" || entry[0] == "i" || entry[0] == "o" || entry[0] == "u" ) {
28+
return true;
29+
}
30+
return false;
31+
};
2132
// Be sure to test your code!
33+
34+
console.log(getValidInput('Enter a word: ', isValidEntry2))

more-on-functions/chapter-examples/receieve-function-arguments/package-lock.json

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

objects-and-math/chapter-examples/ForInLoop.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ let tortoiseOne = {
66
diet: ["pumpkins", "lettuce", "cabbage"]
77
};
88

9-
// Using a for..in loop, iterate through each property in the tortoiseOne object and print the value to the console.
9+
// Using a for..in loop, iterate through each property in the tortoiseOne object and print the value to the console.
10+
for (thing in tortoiseOne) {
11+
console.log(thing + ': ' + tortoiseOne[thing])
12+
}

objects-and-math/chapter-examples/KindnessSelection.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ function randomSelection(arr){
77

88
let words = ['Hello', 'World', 'Python', 'JavaScript', 'Rutabaga'];
99

10-
for (i=0; i < 8; i++){
10+
let happyWords = [happiness, words];
11+
for (i=0; i < 3; i++){
1112
console.log(randomSelection(happiness));
13+
console.log(randomSelection(words));
1214
}
1315

1416
//Experiment with the code above. Try to:

objects-and-math/studio/ObjectsStudio01.js

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
// Code your selectRandomEntry function here:
2-
3-
4-
// Code your buildCrewArray function here:
5-
6-
7-
let idNumbers = [291, 414, 503, 599, 796, 890];
8-
91
// Here are the candidates and the 'animals' array:
102
let candidateA = {
113
'name':'Gordon Shumway',
@@ -52,4 +44,40 @@ let candidateF = {
5244

5345
let animals = [candidateA,candidateB,candidateC,candidateD,candidateE,candidateF];
5446

47+
let idNumbers = [291, 414, 503, 599, 796, 890];
48+
// Code your selectRandomEntry function here:
49+
50+
function selectRandomEntry(numbersArray) {
51+
let index = Math.floor(Math.random() * numbersArray.length);
52+
return numbersArray[index];
53+
}
54+
// Code your buildCrewArray function here:
55+
let crewIds = []
56+
let selectedCrew = []
57+
58+
while (crewIds.length < 3) {
59+
let randomId = selectRandomEntry(idNumbers);
60+
if(!crewIds.includes(randomId)) {
61+
crewIds.push(randomId);
62+
}
63+
}
64+
function buildCrewArray(idNumbers, animals) {
65+
for (let i = 0; i < animals.length; i++) {
66+
if (crewIds.includes(animals[i].astronautID)) {
67+
selectedCrew.push(animals[i])
68+
}
69+
}
70+
return selectedCrew
71+
}
72+
73+
74+
75+
76+
77+
78+
5579
// Code your template literal and console.log statements:
80+
81+
buildCrewArray(idNumbers, animals)
82+
console.log(selectedCrew)
83+
console.log(`${selectedCrew[0].name}, ${selectedCrew[1].name}, and ${selectedCrew[2].name} are going to space!`)

objects-and-math/studio/ObjectsStudio02.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
// Code your orbitCircumference function here:
2-
2+
function orbitCircumference(altitude) {
3+
4+
return Math.round(2 * Math.PI * altitude);
5+
}
6+
// console.log(orbitCircumference(2000))
37

48
// Code your missionDuration function here:
59

6-
10+
function missionDuration(numOrbits, orbitRadius = 2000, orbitSpeed = 28000){
11+
let circumference = orbitCircumference(orbitRadius);
12+
let distance = numOrbits * circumference;
13+
let time = Math.round(100 * distance/speed) / 100;
14+
console.log(`The mission will travel ${distance} km around the planet, and it will taked ${time} hours to complete.`)
15+
}
716
// Copy/paste your selectRandomEntry function here:
817

18+
function selectRandomEntry(numbersArray) {
19+
let index = Math.floor(Math.random() * numbersArray.length);
20+
return numbersArray[index];
21+
}
922

1023
// Code your oxygenExpended function here:
1124

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stringing-characters-together/code-snippets/mad-libs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ let adjective = ;
55
let color = ;
66

77
console.log("JavaScript provides a "+ color +" collection of tools — including " + adjective + " syntax and " + pluralNoun + " — that allows "+ name +" to "+ verb +" with strings.")
8+
9+
console.log(`JavaScript provides a ${color} collection of tools — including ${adjective} syntax and ${pluralNoun} — that allows ${name} to ${verb} with strings.`)

stringing-characters-together/code-snippets/method-chaining.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ console.log(word.toUpperCase());
77

88
//What does ``word.slice(4).toUpperCase()`` return?
99

10-
10+
console.log(word.slice(4).toUpperCase())
1111
//Experiment with other combinations (chains) of string methods.

0 commit comments

Comments
 (0)