Skip to content

Commit 12b3c00

Browse files
committed
Re-organised files and folders
1 parent 2b20fc0 commit 12b3c00

File tree

187 files changed

+2110
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+2110
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function checkScope() {
2+
let i = 'function scope';
3+
if (true) {
4+
let i = 'block scope';
5+
console.log('Block scope i is: ', i);
6+
}
7+
console.log('Function scope i is: ', i);
8+
return i;
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const s = [5, 7, 2];
2+
function editInPlace() {
3+
4+
s[0] = 2;
5+
s[1] = 5;
6+
s[2] = 7;
7+
console.log(s);
8+
}
9+
editInPlace();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function freezeObj() {
2+
const MATH_CONSTANTS = {
3+
PI: 3.14
4+
};
5+
Object.freeze(MATH_CONSTANTS);
6+
try {
7+
MATH_CONSTANTS.PI = 99;
8+
} catch(ex) {
9+
console.log(ex);
10+
}
11+
return MATH_CONSTANTS.PI;
12+
}
13+
const PI = freezeObj();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const magic = () => {
2+
return new Date();
3+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const myConcat = (arr1, arr2) => {
2+
return arr1.concat(arr2);
3+
};
4+
5+
console.log(myConcat([1, 2], [3, 4, 5]));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const increment = (number, value = 1) => number + value;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const sum = (...args) => {
2+
return args.reduce((a, b) => a + b, 0);
3+
}
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
2+
let arr2;
3+
4+
arr2 = [...arr1];
5+
6+
console.log(arr2);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const HIGH_TEMPERATURES = {
2+
yesterday: 75,
3+
today: 77,
4+
tomorrow: 80
5+
};
6+
7+
const {today, tomorrow} = HIGH_TEMPERATURES;
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const HIGH_TEMPERATURES = {
2+
yesterday: 75,
3+
today: 77,
4+
tomorrow: 80
5+
};
6+
7+
const { today: highToday, tomorrow: highTomorrow } = HIGH_TEMPERATURES;
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const LOCAL_FORECAST = {
2+
yesterday: { low: 61, high: 75 },
3+
today: { low: 64, high: 77 },
4+
tomorrow: { low: 68, high: 80 }
5+
};
6+
7+
const { today: { low: lowToday, high: highToday }} = LOCAL_FORECAST;
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let a = 8, b = 6;
2+
[a, b] = [b, a];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const source = [1,2,3,4,5,6,7,8,9,10];
2+
function removeFirstTwo(list) {
3+
4+
const [,,...arr] = list;
5+
return arr;
6+
}
7+
const arr = removeFirstTwo(source);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const stats = {
2+
max: 56.78,
3+
standard_deviation: 4.34,
4+
median: 34.54,
5+
mode: 23.87,
6+
min: -0.75,
7+
average: 35.85
8+
};
9+
10+
const half = ({ max, min }) => (max + min) / 2.0;
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const result = {
2+
success: ["max-length", "no-amd", "prefer-arrow-functions"],
3+
failure: ["no-var", "var-on-top", "linebreak"],
4+
skipped: ["no-extra-semi", "no-dup-keys"]
5+
};
6+
function makeList(arr) {
7+
const failureItems = [];
8+
for (let i = 0; i < arr.length; i++) {
9+
failureItems.push(`<li class="text-warning">${arr[i]}</li>`);
10+
}
11+
12+
return failureItems;
13+
}
14+
15+
const failuresList = makeList(result.failure);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const createPerson = (name, age, gender) => ({name, age, gender});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const bicycle = {
2+
gear: 2,
3+
setGear(newGear) {
4+
this.gear = newGear;
5+
}
6+
};
7+
bicycle.setGear(3);
8+
console.log(bicycle.gear);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Vegetable {
2+
constructor(name) {
3+
this.name = name;
4+
}
5+
}
6+
7+
const carrot = new Vegetable('carrot');
8+
console.log(carrot.name);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Thermostat {
2+
constructor(fahrenheit) {
3+
this.fahrenheit = fahrenheit;
4+
}
5+
6+
get temperature() {
7+
return (5 / 9) * (this.fahrenheit - 32);
8+
}
9+
10+
set temperature(celsius) {
11+
this.fahrenheit = (celsius * 9.0) / 5 + 32;
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<html>
2+
<body>
3+
<script type="module" src="index.js"></script>
4+
</body>
5+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const uppercaseString = (string) => {
2+
return string.toUpperCase();
3+
}
4+
5+
export const lowercaseString = (string) => {
6+
return string.toLowerCase()
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { uppercaseString } from './string_functions.js';
2+
import { lowercaseString } from './string_functions.js';
3+
4+
uppercaseString("hello");
5+
lowercaseString("WORLD!");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import * as stringFunctions from "./string_functions.js";
2+
3+
stringFunctions.uppercaseString("hello");
4+
stringFunctions.lowercaseString("WORLD!");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function subtract(x, y) {
2+
return x - y;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import subtract from "./math_functions.js";
2+
3+
subtract(7,4);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const makeServerRequest = new Promise((resolve, reject) => {
2+
3+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const makeServerRequest = new Promise((resolve, reject) => {
2+
3+
let responseFromServer;
4+
if(responseFromServer) {
5+
resolve("We got the data");
6+
} else {
7+
reject("Data not received");
8+
}
9+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const makeServerRequest = new Promise((resolve, reject) => {
2+
3+
let responseFromServer = true;
4+
5+
if(responseFromServer) {
6+
resolve("We got the data");
7+
} else {
8+
reject("Data not received");
9+
}
10+
});
11+
12+
makeServerRequest.then(result => {
13+
console.log(result);
14+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const makeServerRequest = new Promise((resolve, reject) => {
2+
3+
let responseFromServer = false;
4+
5+
if(responseFromServer) {
6+
resolve("We got the data");
7+
} else {
8+
reject("Data not received");
9+
}
10+
});
11+
12+
makeServerRequest.catch(error => {
13+
console.log(error );
14+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# Define the parent directory
4+
parent_directory="/mnt/a57ccb77-a765-4dca-b87c-b337ac842dee/Sharedvm/FreeCodeCamp-JavaScript-Algorithms-and-Data-Structures/ES6"
5+
6+
# Define the destination directory
7+
destination_directory="/mnt/a57ccb77-a765-4dca-b87c-b337ac842dee/Sharedvm/FreeCodeCamp-JavaScript-Algorithms-and-Data-Structures/nf"
8+
9+
# Iterate through directories in the parent directory
10+
for dir in "$parent_directory"/*/; do
11+
# Extract the directory name
12+
dirname=$(basename "$dir")
13+
14+
# Move files from each directory to the destination directory and rename them
15+
find "$dir" -type f -exec bash -c 'mv "$1" "$2"/"$3_${1##*/}"' bash {} "$destination_directory" "$dirname" \;
16+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let myString = "Hello, World!";
2+
let myRegex = /Hello/;
3+
let result = myRegex.test(myString);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
2+
let waldoRegex = /Waldo/;
3+
let result = waldoRegex.test(waldoIsHiding);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let petString = "James has a pet cat.";
2+
let petRegex = /cat|dog|fish|bird/;
3+
let result = petRegex.test(petString);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let myString = "freeCodeCamp";
2+
let fccRegex = /freeCodeCamp/i;
3+
let result = fccRegex.test(myString);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let extractStr = "Extract the word 'coding' from this string.";
2+
let codingRegex = /coding/;
3+
let result = extractStr.match(codingRegex);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let twinkleStar = "Twinkle, twinkle, little star";
2+
let starRegex = /twinkle/ig;
3+
let result = twinkleStar.match(starRegex);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let exampleStr = "Let's have fun with regular expressions!";
2+
let unRegex = /.un/;
3+
let result = unRegex.test(exampleStr);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
2+
let vowelRegex = /[aeiou]/gi;
3+
let result = quoteSample.match(vowelRegex);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let quoteSample = "The quick brown fox jumps over the lazy dog.";
2+
let alphabetRegex = /[a-z]/gi;
3+
let result = quoteSample.match(alphabetRegex)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let quoteSample = "Blueberry 3.141592653s are delicious.";
2+
let myRegex = /[h-s2-6]/ig;
3+
let result = quoteSample.match(myRegex);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let quoteSample = "3 blind mice.";
2+
let myRegex = /[^aeiou0-9]/ig;
3+
let result = quoteSample.match(myRegex);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let difficultSpelling = "Mississippi";
2+
let myRegex = /s+/ig;
3+
let result = difficultSpelling.match(myRegex);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let chewieRegex = /A+a*/;
2+
3+
let result = chewieQuote.match(chewieRegex);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let text = "<h1>Winter is coming</h1>";
2+
let myRegex = /<.*?>/;
3+
let result = text.match(myRegex);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let reCriminals = /C+/;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let rickyAndCal = "Cal and Ricky both like racing.";
2+
let calRegex = /^Cal/;
3+
let result = calRegex.test(rickyAndCal);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let caboose = "The last car on a train is the caboose";
2+
let lastRegex = /caboose$/;
3+
let result = lastRegex.test(caboose);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let quoteSample = "The five boxing wizards jump quickly.";
2+
let alphabetRegexV2 = /\w/g;
3+
let result = quoteSample.match(alphabetRegexV2).length;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let movieName = "2001: A Space Odyssey";
2+
let numRegex = /\d/g;
3+
let result = movieName.match(numRegex).length;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let movieName = "2001: A Space Odyssey";
2+
let noNumRegex = /\D/g;
3+
let result = movieName.match(noNumRegex).length;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let username = "JackOfAllTrades";
2+
let userCheck = /^[a-z][a-z]+\d*$|^[a-z]\d\d+$/i;
3+
let result = userCheck.test(username);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let sample = "Whitespace is important in separating words";
2+
let countWhiteSpace = /\s/g;
3+
let result = sample.match(countWhiteSpace);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let sample = "Whitespace is important in separating words";
2+
let countNonWhiteSpace = /\S/g;
3+
let result = sample.match(countNonWhiteSpace);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let ohStr = "Ohhh no";
2+
let ohRegex = /Oh{3,6}\sno/;
3+
let result = ohRegex.test(ohStr);

0 commit comments

Comments
 (0)