Skip to content

Questions and reviews workshop #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions arrays/200.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ const nums = [10,3,5,6,];
nums[6] = 50;

console.log(nums.length);
console.log(nums);
1 change: 1 addition & 0 deletions arrays/300.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function getTail(arr) {
return arr.pop();
};

console.log(alphabet.length);
console.log(`The first letter of the alphabet is ${getHead(alphabet)}`);
console.log(`The last letter of the alphabet is ${getTail(alphabet)}`);
console.log(alphabet.length);
Expand Down
2 changes: 1 addition & 1 deletion arrays/600.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function collectNumbers(list) {

const numbersOnly = [];
for (const item of list) {
if (item === 'string') {
if (typeof item === 'number') {
numbersOnly.push(item);
}
}
Expand Down
2 changes: 1 addition & 1 deletion arrays/700.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Fix anything that doesn't work

function countWords(text) {
return text.split('').length;
return text.split(' ').length;
}


Expand Down
27 changes: 27 additions & 0 deletions arrays/900.js → arrays/900.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

const previousWords = [];



function getPreviousCaseOfWordOne(word) {
for (const previousWord of previousWords) {
if (previousWord.toLowerCase() === word.toLowerCase()) {
Expand All @@ -35,3 +37,28 @@ function getPreviousCaseOfWordTwo(word, words) {
}
return word;
}

// Tests for getPreviousCaseOfWordOne
test('getPreviousCaseOfWordOne returns same word if not seen before', () => {
const result = getPreviousCaseOfWordOne("Hello");
expect(result).toBe("Hello");
});

test('getPreviousCaseOfWordOne returns previous case of word if seen before', () => {
getPreviousCaseOfWordOne("Hello");
const result = getPreviousCaseOfWordOne("HELLO");
expect(result).toBe("Hello");
});

// Tests for getPreviousCaseOfWordTwo
test('getPreviousCaseOfWordTwo returns same word if not in words array', () => {
const words = ["World"];
const result = getPreviousCaseOfWordTwo("Hello", words);
expect(result).toBe("Hello");
});

test('getPreviousCaseOfWordTwo returns previous case of word if in words array', () => {
const words = ["Hello", "World"];
const result = getPreviousCaseOfWordTwo("HELLO", words);
expect(result).toBe("Hello");
});
Loading