Last active
March 9, 2023 14:21
-
-
Save erhanyasar/bf9bd9a6bbfa66cf3c3c0cfadb5f98bc to your computer and use it in GitHub Desktop.
Simple Quiz Solutions
This file contains 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
const object = { | |
'1': 30, | |
'2': 58 | |
}; | |
function objectToArrConverter (obj) { | |
if (Object.entries(obj).length === 0) | |
return []; | |
else { | |
let arr = Object.entries(obj); | |
console.log(arr); | |
return arr; | |
} | |
} | |
objectToArrConverter (object); |
This file contains 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
const arr = ["John", "Taylor", "john"]; | |
function removeDuplicates (array) { | |
let noDuplicate = []; | |
noDuplicate = array.filter((a, b) => array.indexOf(a) === b); | |
console.log(noDuplicate); | |
return noDuplicate; | |
} | |
removeDuplicates (arr); |
This file contains 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
const data = [ | |
{ name: "John", age: 21, budget: 23000 }, | |
{ name: "Steve", age: 32, budget: 40000 }, | |
{ name: "Martin", age: 16, budget: 2700 }, | |
]; | |
function getBudgets(arr) { | |
let sum = 0; | |
arr.forEach((object) => { | |
if (typeof object.budget === "number") sum += object.budget; | |
}); | |
console.log(sum); | |
return sum; | |
} | |
getBudgets(data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment