We have a user profile with a name, lastname, age, profession and salary. And we want to console log everything just like:
"My name is xxx xxx, i'm xxx years old. I work as xxx and make $xxx."An object with of NBA players.
const players = [
{jersey:56,name:"Djounte Murray",position:"Point guard",PPG:2.6},
{jersey:98,name:"Dennis Rodman",position:"Small Forward",PPG:10.8},
{jersey:1,name:"Michael Jordan",position:"Small Forward",PPG:345.6},
{jersey:2,name:"Lebron James",position:"Shooting Guard",PPG:26.7},
{jersey:33,name:"Patrick Ewing",position:"Center",PPG:20.2}
]Now we need to loop the list , and generate new array for each and in addition we must round the RPG down. For example:
“56 - Djounte Murray -- Position: Point guard -- RPP: 2”
const products = [
{name:'Iphone',price:200},
{name:'Motorola',price:70},
{name:'Samsung',price:150},
{name:'Sony',price:98},
{name:'Windows pone',price:10}
];print following:
Name: Iphone Price. - Price: 200$
Name: Motorola Price. - Price: 70$
Name: Samsung Price. - Price: 150$
Name: Sony Price. - Price: 98$
Name: Windows pone Price. - Price: 10$
We have an array of paintings, we need to loop the array and create a new array with messages like:
“The Mona lisa is 200 x 200”
const paintings = [
{name:'Mona lisa',width:200,height:200},
{name:'The scream',width:400,height:600},
{name:'The last supper',width:600,height:700}
]We have a list of cars with a brand and a price, and need to create a new array, convert the price to a different currency, and return a string like
“Ford is 40000 rupies”.
const cars = [
{name:'Ford',price:200},
{name:'Nissan',price:400},
{name:'Nissan',price:600}
]We have a list of channels and we want to create a new array only with the premium channels.
const channels = [
{name:'HBO',premium:true},
{name:'LIFE',premium:false},
{name:'Max',premium:true},
{name:'Cooking channel',premium:false},
{name:'WOBI',premium:false}
];We need to calculate how many Km or Miles the user traveled.
const trips = [
{to:'Brazil',distance:1000},
{to:'Chine',distance: 2500},
{to:'India',distance: 3000}
]We have an object with computers. And what we want to know, HOW many computer we have with MAC and how many with WINDOWS.
const computers = [
{type:'Laptop',price:124, os:'Windows'},
{type:'Desk',price:124, os:'Mac'},
{type:'Desk',price:124, os:'Windows'},
{type:'Laptop',price:124, os:'Mac'},
{type:'Laptop',price:124, os:'Windows'},
];Implement a function removeEven(arr), which takes an array arr in its input and removes all the even elements from a given array.
Input: An array with only odd integers
Output: An array with only odd integers
Example:
Input: [1,2,4,5,10,6,3]
Output: [1,5,3]Write a function capitalize(words) that will take an array of words and return an array of those same words with the first letter of each word capitalized.
Example:
['Hello', 'there!', 'How', 'are', 'you', 'doing?']
=>
['Hello', 'There!', 'How', 'Are', 'You', 'Doing?']Write a function evenOdd(numbers) that will take in an array of integers. It should return an array telling whether each item in the original array is even or odd.
[1, 2, 3, 4, 5]
=>
['odd', 'even', 'odd', 'even', 'odd']Write a function that takes an array of objects of the following format:
{
familyMember: 'Uncle',
age: 52,
location: 'California, USA'
}Return an array of the familyMember properties, including only those family members that are above age 40.
[
{
familyMember: 'Uncle',
age: 52,
location: 'San Diego, CA'
}, {
familyMember: 'Grandpa',
age: 84,
location: 'San Francisco, CA'
}, {
familyMember: 'Sister',
age: 19,
location: 'New York, NY'
}
]
=>
['Uncle', 'Grandpa']Write a function add(numbers) that takes in an array of numbers. Return the sum of the numbers.
[1, 2, 3, 4, 5]
=>
15Array To Object
Write a function toObject(strings) that takes in an array of strings. Return an object that has each of those strings as properties, with a value of true.
toObj(['a', 'b', 'c', 'd'])
=>
{
a:true,
b:true,
c:true,
d:true
}Write a function isSubset(arr1, arr2) that takes in two arrays and returns true if the second array contains all items that are present in the first array. Otherwise return false.
Input arrays will NOT contain arrays, objects, or functions.
isSubset(
['abc', 17, 'def'],
['def', 'abc', null, 17, 24]
);
=> trueImplement a function findMinimum(arr) that finds the smallest number in the given array.
arr = [9,2,3,6]
=> 2Implement a function, reArrange(arr), which sorts the elements so that all the negative elements appear on the left, and all positive elements appear at the right.
we consider zero to be a positive integer for this challenge!
[10,-1,20,4,5,-9,-6]
=>
[-1,-9,-6,10,20,4,5]Test case:
[-1,5,-4,-3] => -1,-3,-4,5
[300,-1,3,0] => -1,300,3,0
[0,0,0,-2] => -2,0,0,0
Answer 14