Functionally does all the work as in the developer test pdf file. I also added a details page.
These instructions will help you set up the project locally on your machine for development and testing purposes.
Before you begin, ensure that you have the following software installed:
- Node.js
- npm (normally comes with Node.js)
- React Native CLI (for running React Native projects)
-
Clone the repository:
git clone https://github.com/ayberkgerey/FamobiTest.git cd FamobiTest npm install npm start # Run the project
const progressStats = {
"archery-mission-lvl": {
"fails": 9,
"gameId": "archery-world-tour",
"playTime": 5291.706,
"wins": 8,
},
"archery-world-mission-1": {
"fails": 9,
"gameId": "archery-world-tour",
"playTime": 981,
"wins": 6,
},
"bubble-woods-mission-1": {
"fails": 19,
"gameId": "bubble-woods",
"playTime": 1206,
"wins": 9,
},
"bubble-woods-mission-lvl": {
"fails": 1,
"gameId": "bubble-woods",
"playTime": 100,
"wins": 2,
},
"candy-bubble-mission-lvl": {
"fails": 6,
"gameId": "candy-bubble",
"playTime": 1558,
"wins": 6,
}
};
const gameStatsArray = Object.values(progressStats).reduce((acc, mission) => {
const { gameId, wins, fails, playTime } = mission;
const existingGameStats = acc.find(stats => stats.gameId === gameId);
if (existingGameStats) {
existingGameStats.wins += wins;
existingGameStats.fails += fails;
existingGameStats.playTime += playTime;
} else {
acc.push({ gameId, wins, fails, playTime });
}
return acc;
}, []);
console.log(gameStatsArray);