Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const axios = require('axios');
- async function getNumDraws(year) {
- const url = await `https://jsonmock.hackerrank.com/api/football_matches?year=2011`;
- let total = await 0;
- let count = await 0;
- await axios.get(url).then((data) => {
- total = data.data.total_pages;
- var count = 0;
- for (let i = 1; i <= 5; i++) {
- const url2 = `https://jsonmock.hackerrank.com/api/football_matches?year=2011&page=${i}`;
- axios.get(url2).then((data2) => {
- return data2.data.data.map((e, i) => {
- if (+e.team1goals === +e.team2goals) {
- count = count + 1;
- console.log('Hey: ' + count);
- }
- });
- });
- }
- });
- return count;
- }
- console.log(getNumDraws(2011));
Add Comment
Please, Sign In to add comment