This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (let i = 0; i < mainArray.length; i++) { | |
for (let j = 0; j < otherArray.length; j++) { | |
if (mainArray[i].commonKey === otherArray[j].commonKey) { | |
mainArray[i].newKey = otherArray[j] | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.get('/rated', (req, res) => { | |
db.rating | |
.findAll({ | |
where: { userId: res.locals.currentUser.id } | |
}) | |
.then(responses => { | |
let books = [] | |
for (let i = 0; i < responses.length; i++) { | |
books[i] = { | |
id: responses[i].bookId, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function maxOfThree(num1, num2, num3) { | |
if (num1 > num2 && num1 > num3) { | |
return num1; | |
} else if (num2 > num1 && num2 > num3) { | |
return num2; | |
} else if (num3 > num1 && num3 > num2) { | |
return num3; | |
} else if (num1 === num2 === num3) { | |
return "These numbers are identical."; | |
} else if (num1 === num2 || num2 === num3 || num1 === num3) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tripler(array) { | |
// Confirm in the function | |
console.log('Inside the tripler() function:'); | |
// Take in an array, and return a new array | |
const result = []; | |
// Iterate through array passed in | |
for (let i = 0; i < array.length; i++) { | |
let num = array[i]; | |
// Multiply each element by 3 | |
let multiple = num * 3; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mqr(raw_data): | |
sorted_data = sorted(raw_data) | |
count = len(sorted_data) | |
fifth = math.ceil(count / 5.0) | |
contenders = [] | |
num = 0 | |
while num < count - fifth: | |
contenders.append(sorted_data[num + fifth - 1] - sorted_data[num]) | |
num += 1 | |
return contenders |