part2.js 439 B

12345678910111213141516
  1. const fs = require('fs')
  2. let data = JSON.parse(fs.readFileSync('./Day 1/data.json'))
  3. data.forEach(element => {
  4. data.forEach(element2 => {
  5. data.forEach(element3 => {
  6. if (element + element2 + element3 == 2020) {
  7. let answer = element * element2 * element3
  8. console.log(element + " " + element2 + " " + element3)
  9. console.log(answer)
  10. }
  11. })
  12. })
  13. });