Posts

Showing posts from September, 2018

FreeCodeCamp Wherefore Art Thou Solution

FreeCodeCamp Wherefore Art Thou  Solution function whatIsInAName(collection, source) {   // What's in a name?   var arr = [];   // Only change code below this line   //return Object.keys(source);   var sourceKeys = Object.keys(source);   var sourceValues = Object.values(source);   for(var i=0; i<collection.length; i++){     var collectionKeys = Object.keys(collection[i]);     var collectionValues = Object.values(collection[i]);       var allKeysTrue = true;     var allValuesTrue = true;     for(var j=0; j<sourceKeys.length; j++){           if(!collectionKeys.toString().includes(sourceKeys[j].toString())){         allKeysTrue = false;       }           if(!collectionValues.toString().includes(sourceValues[j].toString())){         allValuesTrue = false;...

frreecode camp-Basic JavaScript: Accessing Nested Arrays

Basic JavaScript: Accessing Nested Arrays As we have seen in earlier examples, objects can contain both nested objects and nested arrays. Similar to accessing nested objects, Array bracket notation can be chained to access nested arrays. Here is an example of how to access a nested array: var ourPets = [   {     animalType: "cat",     names: [       "Meowzer",       "Fluffy",       "Kit-Cat"     ]   },   {     animalType: "dog",     names: [       "Spot",       "Bowser",       "Frankie"     ]   } ]; ourPets[0].names[1]; // "Fluffy" ourPets[1].names[0]; // "Spot" Retrieve the second tree from the variable myPlants using object dot and...

Basic JavaScript: Accessing Nested Objects

Basic JavaScript: Accessing Nested Objects The sub-properties of objects can be accessed by chaining together the dot or bracket notation. Here is a nested object: var ourStorage = {   "desk": {     "drawer": "stapler"   },   "cabinet": {     "top drawer": {       "folder1": "a file",       "folder2": "secrets"     },     "bottom drawer": "soda"   } }; ourStorage.cabinet["top drawer"].folder2; // "secrets" ourStorage.desk.drawer; // "stapler" Access the myStorage object and assign the contents of the glove box property to the gloveBoxContents variable. Use bracket notation for properties with a space in their name. SOLUTION:-----------------------  // Setup var myStorage = { "car" : { "inside" : { "glove box" : "maps" , "passeng...

EDABIT:Return the Last Item in an Array

Return the Last Item in an Array Create a function that accepts an array and returns the last item in the array. Examples [1, 2, 3] ➞ 3 ['cat', 'dog', 'duck'] ➞ 'duck' [true, false, true] ➞ true Notes Don't forget to return the result. All test cases contain valid data types. If you get stuck on a challenge, find help in the Resources tab. If you're really stuck, unlock solutions in the Solutions tab. SOLUTION: function getLastItem(arr) {     var c = arr.pop();     return c; }

Basic JavaScript: Manipulating Complex Objects.

Basic JavaScript: Manipulating Complex Objects. SOLUTION :IN  this challenge , what you need to do is simply push element into array . although sentences at first might look difficult and tough, but it's preety easy. Basic JavaScript: Manipulating Complex Objects. var myMusic = [   {     "artist": "Billy Joel",    "title": "Piano Man",     "release_year": 1973,    "formats": [       "CD",       "8T",      "LP"     ],    "gold": true   }  // Add record here ]; myMusic.push({   "artist":"aastha mishra",   "title":"love me if you could",   "release_year":2018,   "formats":[     "PENDRIVE",    "YOUTUBE",      "MYSAP"       ] } );