Skip to content

Commit 2eb788f

Browse files
committed
Updated
1 parent 095956c commit 2eb788f

File tree

15 files changed

+3908
-3
lines changed

15 files changed

+3908
-3
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
const input = require('readline-sync');
2+
3+
let myString = "Where does the .push() method put things in an array?";
4+
console.log(myString);
5+
myString[0] = "w";
6+
console.log(myString);
7+
8+
myString = "where does the .push() method put things in an array?";
9+
console.log(myString);
10+
11+
12+
let myString = "Where does the .push() method put things in an array?";
13+
console.log(myString);
14+
myString = myString.replace("Where", "Who");
15+
console.log(myString);
16+
17+
let myString = "Where does the .push() method put things in an array?";
18+
console.log(myString.indexOf("y"));
19+
20+
let myString = "Where does the .push() method put things in an array?";
21+
console.log(myString.indexOf("Where"));
22+
23+
let myString = "Where does the .push() method put things in an array?";
24+
console.log(myString.indexOf("o", 8));
25+
26+
let myString = "Where does the .push() method put things in an array?";
27+
console.log(myString.indexOf("o", (myString.indexOf("o") + 1)));
28+
29+
let myName = input.question("What is your name?").toLowerCase();
30+
31+
if (myName === "drareg") {
32+
console.log("Very funny. /s");
33+
} else {
34+
console.log("Good afternoon! :)");
35+
}
36+
37+
if (myName.toLowerCase() === "drareg") {
38+
console.log("Very funny. /s");
39+
} else {
40+
console.log("Good afternoon! :)");
41+
}
42+
43+
let myString = "Banana Cat";
44+
console.log(myString);
45+
console.log(myString.trim());
46+
console.log(myString);
47+
48+
let myString = "Banana Cat";
49+
50+
console.log(myString.slice(1));
51+
52+
let myString = "JavaScript";
53+
let letterJ = myString.slice(0, 1); // "J"
54+
let letterS = myString.slice((myString.indexOf("S")), myString.indexOf ("S") + 1); //"S"
55+
console.log(myString.slice(0, 1) + myString.slice(4, 5));
56+
console.log(`${letterJ}${letterS}`);
57+
58+
/* J
59+
JS */
60+
61+
let myArray = ["Gerard", "Teacher", "Very Tall", 32, false];
62+
console.log(myArray);
63+
64+
let myArray = ["Gerard", "Teacher", "Very Tall", 32, false];
65+
console.log(myArray[4]);
66+
// false
67+
//length = 6
68+
69+
let myArray = ["Gerard", "Teacher", "Very Tall", 32, false];
70+
console.log(myArray[2].length);
71+
//9 = length of item 2
72+
73+
//Boolean = undefined
74+
75+
let myArray = ["Gerard", "Teacher", "Very Tall", 32, false, undefined];
76+
console.log(myArray.indexOf("Gerard"));
77+
// Or console.log(myArray[0].indexOf("s"));
78+
// Would get -1
79+
// console.log(myArray[myArray.indexOf("Gerard")].indexOf("s"));
80+
// This would produce -1
81+
82+
let myArray = ["Gerard", "Teacher", "Very Tall", 32, false, undefined];
83+
console.log(myArray.pop());
84+
// undefined
85+
86+
let myArray = ["Gerard", "Teacher", "Very Tall", 32, false, undefined];
87+
console.log(myArray.shift());
88+
// Gerard
89+
90+
let myArray = ["Gerard", "Teacher", "Very Tall", 32, false, undefined];
91+
let newArray = [];
92+
console.log(myArray);
93+
newArray.unshift(myArray[0]); // Gerard
94+
newArray.unshift(myArray[1]); // Teacher, Gerard
95+
newArray.unshift(myArray[2]); // Very Tall, Teacher, Gerard
96+
newArray.unshift(myArray[3]); // 32, Very Tall, Teacher, Gerard
97+
newArray.unshift(myArray[4]); // false, 32, Very Tall, Teacher, Gerard
98+
newArray.unshift(myArray[5]); // undefined, false, 32, Very Tall, Teacher, Gerard
99+
console.log(newArray);
100+
101+
let arrayOne = ["Gerard", "Teacher", "Very Tall", 32, false ];
102+
let arrayTwo = ["Banana Cat", "Banana Cat", "Very Yellow", 4, true];
103+
let animalList = "Banana Cat, Apple Dog, Mango Zebra, Kiwi Kiwi";
104+
105+
let animalArray = animalList.split(",");
106+
console.log(animalArray);
107+
108+
let animalArray = animalList.split(",");
109+
let restringedArray = animalArray.join("");
110+
// If join has banana and cat emojis in quotes, then banana and cat emojis will be between each item in the list
111+
console.log(restringedArray);
112+
113+
arrayToString = arrayOne.join(", "); // "Gerard, Teacher, Very Tall, 32, false"
114+
let stringBackToArray = arrayToString.split(", "); // ["Gerard", "Teacher", "Very Tall", "32", "false"]
115+
116+
const input = require ('readline-sync');
117+
118+
let fruit = ["Banana", "Pineapple", "Mango", "Dragonfruit", "Jackfruit" ];
119+
let greens = ["Carrot leaves", "Green Beans", "Broccoli?", "Brussels Sprouts", "Zucchini" ];
120+
let pantry = [fruit, greens];
121+
122+
let greensInPantry = pantry[1];
123+
console.log(pantry[1][2]);
124+
console.log(greensInPantry[2]);
125+
console.log(pantry[0][1]);
126+
// This gets to first index of fruit and then the second position of Pineapple.
127+
128+
let isolatedFruits = pantry [0];
129+
console.log(isolatedFruits[isolatedFruits.indexOf("Pineapple")]);
130+
console.log(pantry.indexOf("Pineapple"));
131+
console.log(pantry[0][pantry[0].indexOf("Pineapple")]);
132+

arrays/exercises/part-one-arrays.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//Create an array that can hold 4 items name practiceFile.
2-
2+
//will get back to this later
3+
code
34
//Use the bracket notation method to add "42" and "hello" to the array. Add these new items one at a time. Print the array after each step to confirm the changes.
45

56
//Use a SetValue to add the items "false", and "-4.6" to the array. Print the array to confirm the changes.

arrays/studio/string-modification.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ let str = "LaunchCode";
33

44
//1) Use string methods to remove the first three characters from the string and add them to the end.
55
//Hint - define another variable to hold the new string or reassign the new string to str.
6-
6+
let slicedLetters1 = str.slice(0,3);
7+
let slicedLetters2 = str.slice(3);
8+
console.log(slicedLetters1);
9+
console.log(slicedLetters2);
10+
let pigLatin = slicedLetters2 + slidedLetters1;
11+
console.log(pigLatin);
712
//Use a template literal to print the original and modified string in a descriptive phrase.
8-
13+
console.log(`${str} in pigLatin looks like this: ${pigLatin}.`);
914
//2) Modify your code to accept user input. Query the user to enter the number of letters that will be relocated.
1015

1116
//3) Add validation to your code to deal with user inputs that are longer than the word. In such cases, default to moving 3 characters. Also, the template literal should note the error.

node_modules/.package-lock.json

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

node_modules/readline-sync/LICENSE

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

node_modules/readline-sync/README-Deprecated.md

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

0 commit comments

Comments
 (0)