DEV Community

Cover image for JavaScript objects for beginners
Esraa Nasr
Esraa Nasr

Posted on

JavaScript objects for beginners

Hey guys

From HackerRank challenge 7 Days of JavaScript Day 2: objects

First of all, What are objects?
Objects are variables too, but objects can contain many values.
another definition is the object is a different way of organizing information in JavaScript

for example
var myObject = {type:"Kia", model:2023, color:"red"};

Accessing Object Properties
You can access object properties in two ways:
objectName.propertyName or objectName["propertyName"]

Task 1
In this example, you are given a single line consisting of property type values of a car in the following order:

TypeName ModelName ColorName

These values are assigned to an object car that has the properties type, model, and color (read the code in the editor carefully to learn how that is done). Your task is to complete the code to print the object.

Image description

Take your time and think about a solution then check my solution.

Image description

The next step learning how displaying Information contained in Objects

Image description

I'm thinking of using if statement for the condition and I'm taking a long time to think about how to iterate over an object variable. loop!! yes using for statement.

Do you write code? If yes or no you can check my solution.

Image description

That's all the things I'm learning today what about you?

let's share our knowledge and tell me what you learned today.

Here are my social links if you would like to follow.

Github: https://github.com/EsraaNasr92/
Twitter / X: https://twitter.com/Esraa_nasr92
Instgram: https://www.instagram.com/_esraaanasr/

Top comments (0)