Merge pull request #216 from icorvus/solutions

This commit is contained in:
Michael Frank 2022-01-27 10:15:39 +13:00 committed by GitHub
commit 7df108c5de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 13 deletions

View File

@ -1,8 +1,8 @@
const findTheOldest = function(array) {
return array.reduce((oldest, currentPerson) => {
const oldestAge = getAge(oldest.yearOfBirth, oldest.yearOfDeath)
const currentAge = getAge(currentPerson.yearOfBirth, currentPerson.yearOfDeath)
return oldestAge < currentAge ? currentPerson : oldest
const oldestAge = getAge(oldest.yearOfBirth, oldest.yearOfDeath);
const currentAge = getAge(currentPerson.yearOfBirth, currentPerson.yearOfDeath);
return oldestAge < currentAge ? currentPerson : oldest;
})
};

View File

@ -1,5 +1,5 @@
const getTheTitles = function(array) {
return array.map(book => book.title)
return array.map(book => book.title);
};
module.exports = getTheTitles;

View File

@ -1,5 +1,5 @@
const helloWorld = function() {
return 'Hello, World!'
return 'Hello, World!';
};
module.exports = helloWorld;

View File

@ -1,5 +1,5 @@
const leapYears = function(year) {
return year % 4 === 0 && ( year % 100 !== 0 || year % 400 === 0)
return year % 4 === 0 && ( year % 100 !== 0 || year % 400 === 0);
};
module.exports = leapYears;

View File

@ -1,10 +1,10 @@
const repeatString = function(word, times) {
if (times < 0) return 'ERROR'
let string = ''
if (times < 0) return 'ERROR';
let string = '';
for (let i = 0; i < times; i++) {
string += word
string += word;
}
return string
return string;
};
module.exports = repeatString;

View File

@ -1,5 +1,5 @@
const reverseString = function(string) {
return string.split('').reverse().join('')
return string.split('').reverse().join('');
};
module.exports = reverseString;

View File

@ -1,9 +1,9 @@
const ftoc = function(f) {
return Math.round((f - 32) * (5/9) * 10) / 10
return Math.round((f - 32) * (5/9) * 10) / 10;
};
const ctof = function(c) {
return Math.round(((c * 9/5) + 32) * 10) / 10
return Math.round(((c * 9/5) + 32) * 10) / 10;
};