From bb585e042a09dfca0e4c5e18f229b1e820391d80 Mon Sep 17 00:00:00 2001 From: Franco Date: Sun, 13 Oct 2019 23:14:13 -0400 Subject: [PATCH] practice-1 --- practice.js | 61 ++++++++++++++++++++++++++++++++++++++++++++--------- user.json | 4 ++-- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/practice.js b/practice.js index 82a0b55..5ff2011 100644 --- a/practice.js +++ b/practice.js @@ -15,7 +15,11 @@ */ //Code here - +let me = { + name: 'Francisco Ifurung', + age: '21' +} +console.log(me.name); ////////// PROBLEM 2 ////////// /* @@ -27,21 +31,29 @@ */ // Code here - +let favoriteThings = { + band: 'FOB', + food: 'adobo', + person: 'Franco', + movie: 'Pulp Fiction', + holiday: 'Christmas' +} /* After you've made your object, use bracket or dot notation to add another key named 'car' with the value being your favorite car and then another key named 'brand' with the value being your favorite brand. */ //Code here - +favoriteThings.car = "Poseidon"; +favoriteThings.brand = "Hollister"; /* Now use bracket or dot notation to change the value of the food key in your favoriteThings object to be 'Chicken Nuggets' and change the value of the book key in your favoriteThings object to be 'Harry Potter'. */ //Code here - +favoriteThings.food = "Chicken Nuggets"; +favoriteThings.book = "Harry Potter"; ////////// PROBLEM 3 ////////// /* @@ -53,13 +65,19 @@ */ //Code here +let backPack = {} + +var item = "firstPocket"; +backPack[item] = ''; +backPack[item] = 'chapstick'; +backPack.color = "black"; /* After you do the above, alert your entire backPack object. */ //Code here - +console.log(backPack.firstPocket, backPack.color); /* You probably noticed that it just alerted [object Object]. Alerting to see the data in your Object doesn't work so well. @@ -67,7 +85,7 @@ Instead, console.log your whole backPack object and then check out the console. */ //Code here - +console.log(backPack); ////////// PROBLEM 4 ////////// // Do not edit the code below. @@ -88,7 +106,8 @@ var user2 = { */ //Code Here - +user2.name = 'Aodhan Hayter'; +user2.email = 'aodhan@boom.camp'; /////////////////////// EXTRA PRACTICE PROBLEMS BELOW //////////////////// ////////// MOVE ONTO NEXT SECTION BEFORE WORKING ON THESE //////////////// @@ -99,20 +118,26 @@ var user2 = { */ //Code Here - +var methodCollection = {} /* Now add two methods (functions that are properties on objects) to your methodCollection object. One called 'alertHello' which alerts 'hello' and another method called 'logHello' which logs 'hello' to the console. */ //Code Here - +methodCollection.alertHello = function() { + alert('hello'); +} +methodCollection.logHello = function() { + console.log('hello'); +} /* Now call your alertHello and logHello methods. */ //Code Here - +methodCollection.alertHello(); +methodCollection.logHello(); ////////// PROBLEM 6 ////////// /* @@ -121,6 +146,14 @@ var user2 = { */ //Code Here +function makePerson(name, birthday, ssn){ + return { + name: name, + birthday: birthday, + ssn: ssn + } +} + ////////// PROBLEM 7 ////////// @@ -130,3 +163,11 @@ var user2 = { */ //Code Here +function makeCard(cardNumber, expirationDate, securityCode){ + var credit_card = { + cardNumber: cardNumber, + expirationDate: expirationDate, + securityCode: securityCode + } + return credit_card; +} \ No newline at end of file diff --git a/user.json b/user.json index 4ac80a0..987ce8f 100644 --- a/user.json +++ b/user.json @@ -1,4 +1,4 @@ { - "name": "", - "email": "" + "name": "Francisco R. Ifurung", + "email": "francisco.ifurung@boom.camp" }