Guest User

Untitled

a guest
Oct 10th, 2020
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. const axios = require('axios');
  2.  
  3. async function getNumDraws(year) {
  4. const url = await `https://jsonmock.hackerrank.com/api/football_matches?year=2011`;
  5. let total = await 0;
  6. let count = await 0;
  7. await axios.get(url).then((data) => {
  8. total = data.data.total_pages;
  9. var count = 0;
  10. for (let i = 1; i <= 5; i++) {
  11. const url2 = `https://jsonmock.hackerrank.com/api/football_matches?year=2011&page=${i}`;
  12. axios.get(url2).then((data2) => {
  13. return data2.data.data.map((e, i) => {
  14. if (+e.team1goals === +e.team2goals) {
  15. count = count + 1;
  16. console.log('Hey: ' + count);
  17. }
  18. });
  19. });
  20. }
  21. });
  22. return count;
  23. }
  24. console.log(getNumDraws(2011));
  25.  
Add Comment
Please, Sign In to add comment