function data(name, age) {
  var biodata = {
    name: "meme ",
    age: "17",
    address: "Malang",
    hobbies: ["reading, hearing podcast"],
    is_married: false,
    list_school: [{
        name: "SMKN 5 Malang",
        year_in: 2016,
        year_out: 2018,
        major: "Rekayasa Perangkat Lunak"
      },
      {
        name: "SMKN 5 Malang",
        year_in: 2016,
        year_out: 2018,
        major: "Teknik Komputer Jaringan"
      }
    ],
    skill: [{
        name: "Programming",
        level: "Beginner"
      },
      {
        name: "Gaming",
        level: "Advanced"
      },
      {
        name: "Driving",
        level: "Advanced"
      },
    ],
    interest_in_coding: false
  };
  final = JSON.parse(nama + age + address + hobbies + is_married + list_school + skill + interest_in_coding)

}
return final
-3
kui beatbox 4 nov. 2019 à 13:12

1 réponse

Solution parfaite pour votre sortie désirée La fonction que j'ai utilisée dans ce

JSON.stringify(obj, replacer, space)

S'il vous plaît vérifier le code JavaScript se concentrer fortement sur ce code

JSON.stringify (biodonnées, non défini, 4);

function data(name,age) {
var el_down = document.getElementById("DOWN"); 
  var biodata = {
    name: "meme ",
    age: "17",
    address: "Malang",
    hobbies: ["reading, hearing podcast"],
    is_married: false,
    list_school: [{
        name: "SMKN 5 Malang",
        year_in: 2016,
        year_out: 2018,
        major: "Rekayasa Perangkat Lunak"
      },
      {
        name: "SMKN 5 Malang",
        year_in: 2016,
        year_out: 2018,
        major: "Teknik Komputer Jaringan"
      }
    ],
    skill: [{
        name: "Programming",
        level: "Beginner"
      },
      {
        name: "Gaming",
        level: "Advanced"
      },
      {
        name: "Driving",
        level: "Advanced"
      },
    ],
    interest_in_coding: false
  };
  
el_down.innerHTML = JSON.stringify(biodata, undefined, 4); 

}
data("name","age")
<pre id="DOWN" style= "color:green; font-size: 20px; font-weight: bold;"> </pre> 
-1
Hardik Masalawala 4 nov. 2019 à 10:37