Crow's Codes 002: JavaScript Objects

in #coding6 years ago


Image courtesy of Pexels.com

Day Two in my one year quest to develop my coding skills. Every day during this challenge I will post at least one line of code that I've learned or worked on. I've been working through the free Codecademy course Introduction to JavaScript. Today I am exploring JavaScript Objects.

#CodingPhase #TheCodingWay #365CodingPhaseChallenge


My first task was to define a new object called fasterShip with two properties. This is the code I came up with:

let fasterShip = { 'Fuel Type': 'Turbo Fuel', color: 'silver' };

Next I was presented with the following code which defines an object with five properties:

let spaceship = {
  homePlanet: 'Earth',
  color: 'silver',
  'Fuel Type': 'Turbo Fuel',
  numCrew: 5,
  flightPath: ['Venus', 'Mars', 'Saturn']
};

The lesson had me assign the value of a property containing a number to a variable. This is the successful code I came up with:

const crewCount = spaceship.numCrew;

I was next asked to try assigning an array of strings to a variable. I accomplished this in the same way. My code was:

const planetArray = spaceship.flightPath;

I also learned how to access the value of a property within an object using square brackets. The following code is one example I wrote to access the color of the spaceship from the object definition above and assign it to a variable:

const whatColor = spaceship['color'];

I also learned that an object defined using const cannot be reassigned but it can be mutated (i.e. modified) to add, change or remove property values.

Also, if you assign a function as a value to a property within an object, that property is considered to be a method and can be utilized as such.

This is just a bit of what I learned today. If I documented all of it, I would never get through the lessons! Have a great day coding and I'll see you here again tomorrow. :)



If you enjoyed this record of my experience learning to code and want to follow along going forward, please consider adding me on Twitter and following my blog here on Steemit:
https://steemit.com/@jeremycrow


Connect with me on:

My Website: JeremyCrow.com
Minds: Minds.com/JeremyCrow
Twitter: Twitter.com/JeremyCrow
Patreon: Patreon.com/jeremycrow
Instagram: Instagram.com/jeremycrow
YouTube: YouTube.com/user/ZigguratOfEnki
BitChute: BitChute.com/JeremyCrow (sign up here)

Sort:  

Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!

Reply !stop to disable the comment. Thanks!

As a follower of @followforupvotes this post has been randomly selected and upvoted! Enjoy your upvote and have a great day!

This post has received a 57.47 % upvote from @steemdiffuser thanks to: @jeremycrow.

Bids above 0.05 SBD may get additional upvotes from our trail members.

Get Upvotes, Join Our Trail, or Delegate Some SP

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by JeremyCrow from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63878.47
ETH 2625.83
USDT 1.00
SBD 2.79