LusienGG

[ECMAScript 6] ParseObjects (JSON)

Jun 17th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Created by Lusien.GG on 17-06-16.
  3.  */
  4. 'use strict'
  5. function parseJSON(input) {
  6.     let collection =[]
  7.     for (let i=0; i < input.length; i++){
  8.         collection.push(JSON.parse(input[i]))
  9.     }
  10.     for (let obj of collection){
  11.         console.log(`Name: ${obj.name}`)
  12.         console.log(`Age: ${obj.age}`)
  13.         console.log(`Date: ${obj.date}`)
  14.     }
  15. }
  16. // parseJSON(['{"name":"Gosho","age":10,"date":"19/06/2005"}',
  17. //           '{"name":"Tosho","age":11,"date":"04/04/2005"}'])
Advertisement
Add Comment
Please, Sign In to add comment