From 9c1c0419194ac53d31de24182b5a6b7660eb0d11 Mon Sep 17 00:00:00 2001 From: Dan Marquis Date: Mon, 24 Feb 2020 18:39:41 -0500 Subject: [PATCH] Class updates --- intermediate.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/intermediate.js b/intermediate.js index d6ff14d..d5041a2 100644 --- a/intermediate.js +++ b/intermediate.js @@ -33,5 +33,57 @@ var personInfo = { } }; +//JSON +var json = { + "firstName": "Joe", + "lastName": "Smith", + "state": "CT" +}; + +JSON.stringify(personInfo); + console.log(personInfo.firstName); console.log(personInfo.fullName()); + +var array = ["CT", "MA", "NY", "RI", "NH", "VT", "ME"]; + +console.log(array.length); + +var name = "Frank"; +var length = name.length; + +array.push("PA"); +console.log(array); + +array[0]; // "CT" +array[3]; // "RI" +delete array[1]; +console.log(array); +array.splice(1, 1); + +// var array = ["CT", "MA", "NY", "RI", "NH", "VT", "ME"]; + +//foreach +array.forEach(function(item) { + console.log(item + "!"); +}) + +//DATES +personInfo.createdDate = new Date(); + +var date = new Date(); +console.log(date); + +var stringDate = new Date("02/24/2020"); +var something = new Array(); + +//Try/Catch + +try { + if(something.length > 0) { + alert('The array exists'); + } +} catch { + console.log("There was an error in your try/catch"); +} +