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
45 changes: 30 additions & 15 deletions src/arrays.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,76 @@
const getNthElement = (index, array) => {
// your code here
while (index >= array.length) {
index -= array.length;
}
let answer = array[index];
return answer;
};

const arrayToCSVString = array => {
// your code here
return array.toString();
};

const csvStringToArray = string => {
// your code here
return string.split(",");
};

const addToArray = (element, array) => {
// your code here
array.push(element);
};

const addToArray2 = (element, array) => {
// your code here
return (array2 = array.concat(element));
};

const removeNthElement = (index, array) => {
// your code here
return array.splice(index, 1);
};

const numbersToStrings = numbers => {
// your code here
return numbers.map(String);
};

const uppercaseWordsInArray = strings => {
// your code here
return strings.map(String => {
return String.toUpperCase();
});
};

const reverseWordsInArray = strings => {
// your code here
return strings.map(String => {
return String.split("")
.reverse()
.join("");
});
};

const onlyEven = numbers => {
// your code here
return numbers.filter(Number => {
return Number % 2 === 0;
});
};

const removeNthElement2 = (index, array) => {
// your code here
return array.filter((_, itemIndex) => itemIndex !== index);
};

const elementsStartingWithAVowel = strings => {
// your code here
return strings.filter(String => /^[aeiou]/i.test(String))
};

const removeSpaces = string => {
// your code here
return string.split(" ").join("");
};

const sumNumbers = numbers => {
// your code here
const sum = numbers.reduce((total, amount) => total + amount);
return sum;
};

const sortByLastLetter = strings => {
// your code here
return strings.sort(
(a, b) => a.charCodeAt(a.length - 1) - b.charCodeAt(b.length - 1)
);
};

module.exports = {
Expand Down
91 changes: 74 additions & 17 deletions src/booleans.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,119 @@
const negate = a => {
// your code here
if (a === true) {
return false;
} else {
return true
};
};

const both = (a, b) => {
// your code here
if (a === true && b === true) {
return true;
} else {
return false;
}
};

const either = (a, b) => {
// your code here
if (a || b === true) {
return true;
} else {
return false;
}
};

const none = (a, b) => {
// your code here
if (a === false && b === false) {
return true;
} else {
return false;
}
};

const one = (a, b) => {
// your code here
if ((a === true && b === false) || (a === false && b === true)) {
return true;
} else {
return false;
}
};

const truthiness = a => {
// your code here
return Boolean(a);
};

const isEqual = (a, b) => {
// your code here
if (a === b) {
return true;
} else {
return false;
}
};

const isGreaterThan = (a, b) => {
// your code here
if (a > b) {
return true;
} else {
return false;
}
};

const isLessThanOrEqualTo = (a, b) => {
// your code here
if (a <= b) {
return true;
} else {
return false;
}
};

const isOdd = a => {
// your code here
if (a % 2 === 0) {
return false;
} else {
return true;
}
};

const isEven = a => {
// your code here
if (a % 2 === 0) {
return true;
} else {
return false;
}
};

const isSquare = a => {
// your code here
if (Math.sqrt(a) % 1 === 0) {
return true;
} else {
return false;
}
};

const startsWith = (char, string) => {
// your code here
if (string.charAt(0) === char) {
return true;
} else {
return false;
}
};

const containsVowels = string => {
// your code here
};
let vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"];
for (i = 0; i < vowels.length; i += 1) {
let trueResult = string.includes(vowels[i]);
if (trueResult === true) {
return true;
}
}
return false;
}



const isLowerCase = string => {
// your code here
};
return string === string.toLowerCase();
}

module.exports = {
negate,
Expand Down
22 changes: 11 additions & 11 deletions src/numbers.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
const add = (a, b) => {
// your code here
return a + b;
};

const subtract = (a, b) => {
// your code here
return a - b;
};

const multiply = (a, b) => {
// your code here
return a * b;
};

const divide = (a, b) => {
// your code here
return a / b;
};

const power = (a, b) => {
// your code here
return a ** b;
};

const round = a => {
// your code here
return Math.round(a);
};

const roundUp = a => {
// your code here
return Math.ceil(a);
};

const roundDown = a => {
// your code here
return Math.floor(a);
};

const absolute = a => {
// your code here
return Math.abs(a);
};

const quotient = (a, b) => {
// your code here
return Math.trunc(a / b);
};

const remainder = (a, b) => {
// your code here
return a % b;
};

module.exports = {
Expand Down
39 changes: 28 additions & 11 deletions src/objects.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,58 @@
const createPerson = (name, age) => {
// your code here
const People = {
name: name,
age: age
}
return People;
};

const getName = object => {
// your code here
return object.name;
};

const getProperty = (property, object) => {
// your code here
return object[property];
};

const hasProperty = (property, object) => {
// your code here
return object.hasOwnProperty(property);
};

const isOver65 = person => {
// your code here
if (person.age > 65) {
return true;
} else {
return false;
}
};

const getAges = people => {
// your code here
return people.map(person => person.age);
};

const findByName = (name, people) => {
// your code here
};
return people.find(persons => persons.name === name);
}

const findHondas = cars => {
// your code here
return cars.filter(car => car.manufacturer === "Honda");
};

const averageAge = people => {
// your code here
const totalAge = people.reduce((prevAge, currentPerson) => {
return prevAge + currentPerson.age;
}, 0);
return totalAge / people.length;
};

const createTalkingPerson = (name, age) => {
// your code here
const talkingPerson = {
name: name,
age: age,
introduce: strangersName => { return `Hi ${strangersName}, my name is ${ name } and I am ${ age }!`
}
};
return talkingPerson;
};

module.exports = {
Expand Down
Loading