swati-jagtap / javascript-practice

0 stars 0 forks source link

JSON 16.1.1 to 16.2.1 #154

Open swati-jagtap opened 3 years ago

swati-jagtap commented 3 years ago
//16.1.1--Change skills array to JSON using JSON.stringify()
const skills = ['HTML', 'CSS', 'JS', 'React','Node', 'Python'];
console.log(skills);
console.log(JSON.stringify(skills));

//16.1.2--Stringify the age variable
let age = 250;
console.log(JSON.stringify(age));

//16.1.3--Stringify the isMarried variable
let isMarried = true;
console.log(JSON.stringify(isMarried));
//16.1.4--Stringify the student object
const student = {
    firstName:'Asabeneh',
    lastName:'Yetayehe',
    age:250,
    isMarried:true,
    skills:['HTML', 'CSS', 'JS', 'React','Node', 'Python', ]
  }
  console.log(JSON.stringify(student));

  //16.2.1--Stringify the students object with only firstName, lastName and skills properties
  console.log(JSON.stringify(student,['firstName','lastName','skills'],4));

image