0% found this document useful (0 votes)
22 views27 pages

Ilovepdf Merged

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views27 pages

Ilovepdf Merged

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

8/30/23, 6:46 AM Revolutionizing the Job Market | NxtWave

DOM and Event Fundamentals | Cheat Sheet

1. JavaScript Variables

1.1 Variable Declaration


Variables are like containers for storing
values. We can create a variable using the

let keyword.
JAVASCRIPT

1 let message;

1.2 Assigning a Value to the


Variable

We can put data into a variable using an


assignment operator (

= ).
JAVASCRIPT

1 let message = 'Hello Rahul

JAVASCRIPT

1 let message;
2 message = 'Hello Rahul';

Try out changing the JavaScript Variables and


their Values in the below Code Playground
and check the output in the console.

HTML CSS JAVASCRIPT

1 <!DOCTYPE html>
2 <html>
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=5ada9e21-… 1/5
8/30/23, 6:46 AM Revolutionizing the Job Market | NxtWave
2 <html>
3 <head></head>
4 <body>
5 Your HTML code goes here. W
6 </body>
7 </html>

Note

Printing a variable without


assigning a value will give the
output undefined .

2. Document Object Model


(DOM)

The DOM is the structured representation of


the HTML document created by the browser.
It allows JavaScript to manipulate, structure,
and style your website.
HTML

1 <!DOCTYPE html>
2 <html>
3 <head></head>
4 <body>
5 <h1>Web Technologies</
6 <button>Change Heading
7 </body>
8 </html>

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=5ada9e21-… 2/5
8/30/23, 6:46 AM Revolutionizing the Job Market | NxtWave

2.1 Document Object

It is the entry point of the DOM. For


accessing any HTML Element, you should
always start with accessing the document
object first.

2.2 HTML DOM Tree

The DOM tree represents an HTML


document as nodes. Each node is referred to
as an Object.

2.3 Methods

2.3.1 getElementById

The

getElementById() method helps to select


the HTML Element with a specific ID.
JAVASCRIPT

1 console.log(document.getEl

2.4 Properties

2.4.1 textContent

To manipulate the text within the HTML


Element, we use

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=5ada9e21-… 3/5
8/30/23, 6:46 AM Revolutionizing the Job Market | NxtWave

textContent Property.

2.4.2 style

The

style property is used to get or set a


specific style of an HTML Element using
different CSS properties.

Use Camel Case naming convention (starting


letter of each word should be in the upper
case except for the first word) for naming the
Style Object Properties.

For example,

color , fontFamily , backgroundColor ,


etc.

2.5 Events
Events are the actions by which the user or
browser interacts with the HTML Elements.
Actions can be anything like clicking a
button, pressing keyboard keys, scrolling the
page, etc.

2.5.1 onclick Event

The

onclick event occurs when the user clicks


on an HTML Element. We will give the name
of the function as a value for the HTML
onclick attribute.
HTML

1 <body>
2 <h1 id="headingElement">
3 <button onclick="manipul
4 </body>

JAVASCRIPT

1 f ti i l t St l (
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=5ada9e21-… 4/5
8/30/23, 6:46 AM Revolutionizing the Job Market | NxtWave
1 function manipulateStyles(
2 document.getElementById(
3 document.getElementById(
4 }

HTML CSS JAVASCRIPT

1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="stylesheet" href
5 <script src="https://code.j
6 <script src="https://cdn.j
7 <script src="https://stack
8 </head>
9 <body>
10 <div class="dark-background
11 <div>
12 <img
13 src="https://d1tgh8fm
14 class="bulb-image"
15 id="bulbImage"
16 />
17 </div>

Submit Feedback

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=5ada9e21-… 5/5
8/30/23, 6:48 AM Revolutionizing the Job Market | NxtWave

Primitive Types & Conditionals | Cheat Sheet


1. JavaScript Values

Basically In JavaScript values are of two


categories.

Primitive Types

Reference Types

1.1 Primitive Types


Number

Boolean

String

Undefined, etc.

Primitive Type Description

All the numbers are of Number


Number
type.

Boolean values are either true


Boolean
or false.

String is a stream of characters.


The String should be enclosed
String
with Single quotes, Double
quotes, or Backticks.

If a value is not assigned to the


variable, then it
takes undefined as its
Undefined value. In
JS, undefined refers to
the value that is not being
assigned.

1.2 Operators

1.2.1 typeof()

The

typeof() operator is used to find the type


of value.

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=c5beb3d0-… 1/4
8/30/23, 6:48 AM Revolutionizing the Job Market | NxtWave

JAVASCRIPT

1 let a = 900;
2 let b = 9.2;
3 console.log(typeof(a)); /
4 console.log(typeof(b)); /

Try out changing the different Values in the


below Code Playground and check the
output in the console.

HTML CSS JAVASCRIPT

1 <!DOCTYPE html>
2 <html>
3 <head></head>
4 <body>
5 Your HTML code goes here. W
6 </body>
7 </html>

2. Converting String to a
Number

In JavaScript, when we combine the number


and string, it results in a string.

The

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=c5beb3d0-… 2/4
8/30/23, 6:48 AM Revolutionizing the Job Market | NxtWave

parseInt() function accepts a string and


converts it into an integer.
JAVASCRIPT

1 let a = '20';
2 console.log(typeof(a)); /
3
4 let b = parseInt(a);
5 console.log(typeof(b)); /

3. Conditional Statements

The Conditional Statement allows you to


execute a block of code only when a specific
condition is true.

If...Else Statement:

Syntax:
JAVASCRIPT

1 if (conditionA) {
2 Block1;
3 }
4 else if (conditionB) {
5 Block2;
6 }
7 else {
8 Block3;
9 }

Try out changing the colors, increment, and


decrement Values in the below Code
Playground and check the output.

HTML CSS JAVASCRIPT

1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="stylesheet" href
5 <script src="https://code.j
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=c5beb3d0-… 3/4
8/30/23, 6:48 AM Revolutionizing the Job Market | NxtWave
5 <script src https://code.j
6 <script src="https://cdn.j
7 <script src="https://stack
8 </head>
9 <body>
10 <div class="bg-container te
11 <h1 class="counter-headi
12 <p id="counterValue" cla
13 <div>
14 <button onClick="onDec
15 <button onClick="onRese
16 <button onClick="onInc
17 </div>

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=c5beb3d0-… 4/4
8/30/23, 6:49 AM Revolutionizing the Job Market | NxtWave

Input Element and Math Functions | Cheat Sheet


1. Math Functions

1.1 Math.random()

The

Math.random() function returns a random


number (float value) in range 0 to less than 1 ( 0
<= randomNumber < 1 ).
JAVASCRIPT

1 console.log(Math.random())

1.2 Math.ceil()

The

Math.ceil() function always rounds a


number up to the next largest integer.
JAVASCRIPT

1 console.log(Math.ceil(95.9

Try running the code multiple times and observe


the output in the console.

HTML CSS JAVASCRIPT

1 <!DOCTYPE html>
2 <html>
3 <head></head>
4 <body>
5 Your HTML code goes here. W
6 </body>
7 </html>

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=9298e2a1-… 1/4
8/30/23, 6:49 AM Revolutionizing the Job Market | NxtWave

2. HTML Elements

2.1 HTML Input Element

The HTML

input element creates interactive controls to


accept the data from the user.

There are different types of inputs.

Text

Password

Radio

Date

Checkbox

2.1.1 Text Input


HTML

1 <input type="text" />

Note

Default type for the


HTML input element is text .

2.1.2 Password Input

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=9298e2a1-… 2/4
8/30/23, 6:49 AM Revolutionizing the Job Market | NxtWave

It provides a way for the user to enter a password


securely.
HTML

1 <input type="password" />

3. DOM Properties

3.1 Value

We can use the

value property to get the value of the HTML


input Element.
JAVASCRIPT

1 document.getElementById("i

Try out giving the different input values and


check the output in the below Code Playground.

HTML CSS JAVASCRIPT

1 <!DOCTYPE html>
2 <html>
3 <head></head>
4 <body>
5 <p>Enter your Name</p>
6 <input type="text" id="inp
7 <p>Enter your Password</p>
8 <input type="password" />
9 <div>
10 <button onclick="signIn(
11 </div>
12 <p id="signInText"></p>
13 </body>
14 </html>

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=9298e2a1-… 3/4
8/30/23, 6:49 AM Revolutionizing the Job Market | NxtWave

4. Comparison Operator

4.1 Loose equal to vs Strict equal to


( == vs === )

Loose equal to (

== ): Loose equality compares two values for


equality but doesn’t compare types of values.
Strict equal to ( === ): Strict equality compares
two values for equality including types of values.
JAVASCRIPT

1 console.log(2 == '2'); //
2 console.log(2 === '2'); /

Try out giving the different input values and


check the output in the below Code Playground.

HTML CSS JAVASCRIPT

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=64c6b29b-1c30-4fc9-b45c-2ec92b266c14&s_id=9298e2a1-… 4/4
8/30/23, 6:50 AM Revolutionizing the Job Market | NxtWave

Arrays & More DOM Manipulations | Cheat Sheet


1. Data Structures

Data Structures allow us to store and


organize data efficiently. This makes us
access and performs operations on the data
smoothly.

In JavaScript, we have built-in Data Structures


like,

Arrays

Objects

Maps

Sets

2. Array

An Array holds an ordered sequence of


items.

2.1 Creating an Array


JAVASCRIPT

1 let myArray = [5, "six", 2


2
3 console.log(myArray); //

2.2 Accessing an Array Item


JAVASCRIPT

1 let myArray = [5, "six", 2


2
3 console.log(myArray[0]);
4
5 console.log(myArray[1]);

2.3 Modifying an Array Item


https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=c0caae2e-… 1/7
8/30/23, 6:50 AM Revolutionizing the Job Market | NxtWave

JAVASCRIPT

1 let myArray = [5, "six", 2


2 myArray[1] = 6;
3
4 console.log(myArray); //

2.4 Finding Array Length

The

array.length is used to find the number of


items in the array.
JAVASCRIPT

1 let myArray = [5, "six", 2


2 let lengthOfArray = myArra
3
4 console.log(lengthOfArray)

2.5 Array Methods

2.5.1 push()

The

push() method adds new items to the end


of the array.
JAVASCRIPT

1 let myArray = [5, "six", 2


2 myArray.push(true);
3
4 console.log(myArray); //

2.5.2 pop()

The

pop() method removes the last item of an


array and returns that item.
JAVASCRIPT

1 let myArray = [5, "six", 2


2 let lastItem = myArray.pop
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=c0caae2e-… 2/7
8/30/23, 6:50 AM Revolutionizing the Job Market | NxtWave

3
4 console.log(myArray); //
5
6 console.log(lastItem); //

Try out creating an array, accessing,


modifying its array items, and apply array
methods to them in the below Code
Playground.

HTML CSS JAVASCRIPT

1 let myArray = [5, "six", 2, 8.2


2 myArray[1] = 7;
3 myArray.pop();
4 myArray.push("seven");
5
6 console.log(myArray);

3. Functions

3.1 Function Declaration


JAVASCRIPT

1 function showMessage() {
2 console.log("Hello");
3 }
4
5 showMessage();

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=c0caae2e-… 3/7
8/30/23, 6:50 AM Revolutionizing the Job Market | NxtWave

3.2 Function Expression

There is another syntax for creating a


function which is called Function Expression.
JAVASCRIPT

1 let showMessage = function


2 console.log("Hello");
3 };
4
5 showMessage();

4. More DOM Manipulations

4.1 Creating an HTML Element


- createElement()
JAVASCRIPT

1 let h1Element = document.c


2 h1Element.textContent = "W
3
4 console.log(h1Element); /

4.2 Appending to an HTML


Element - appendChild()

Appending to Document Body


Object:
JAVASCRIPT

1 document.body.appendChild(

Appending to Existing Container


Element:
JAVASCRIPT

1 let containerElement = doc


2 containerElement.appendChi

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=c0caae2e-… 4/7
8/30/23, 6:50 AM Revolutionizing the Job Market | NxtWave

Try out creating and appending the HTML


elements like a paragraph, image, etc. in the
below Code Playground.

HTML CSS JAVASCRIPT

1 let h1Element = document.create


2 h1Element.textContent = "Web Te
3
4 let containerElement = document
5 containerElement.appendChild(h1
6
7 let btnElement = document.creat
8 btnElement.textContent = "Chang
9 containerElement.appendChild(bt

4.3 Adding Event Listeners


Dynamically
JAVASCRIPT

1 let btnElement = document.


2 btnElement.textContent = "
3 document.getElementById("m
4
5 btnElement.onclick = funct
6 console.log("click event
7 };

4.4 Providing Class Names


Dynamically - classList.add()
JAVASCRIPT

1 btnElement.onclick = funct
2 h1Element.textContent =
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=c0caae2e-… 5/7
8/30/23, 6:50 AM Revolutionizing the Job Market | NxtWave

3 h1Element.classList.add(
4
5 console.log(h1Element);
6 };

CSS

1 .heading {
2 color: blue;
3 font-family: "Caveat";
4 font-size: 40px;
5 text-decoration: underli
6 }

4.5 Removing Class Names


Dynamically - classList.remove()
JAVASCRIPT

1 let removeStylesBtnElement
2 removeStylesBtnElement.tex
3
4 document.getElementById("m
5
6 removeStylesBtnElement.onc
7 h1Element.classList.remo
8 };

Try out adding the event listeners, class


names and removing class names
dynamically in the below Code Playground.

HTML CSS JAVASCRIPT

1 let h1Element = document.create


2 h1Element.textContent = "Web Te
3
4 let containerElement = document
5 containerElement.appendChild(h1
6
7 let btnElement = document.creat
8 btnElement.textContent = "Chang
9 containerElement.appendChild(bt
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=c0caae2e-… 6/7
8/30/23, 6:50 AM Revolutionizing the Job Market | NxtWave

10
11 btnElement.onclick = function(
12 h1Element.textContent = "4.0
13 h1Element.classList.add("head
14 };
15
16 let removeStylesBtnElement = do
17 removeStylesBtnElement.textCont

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=c0caae2e-… 7/7
8/30/23, 6:51 AM Revolutionizing the Job Market | NxtWave

Objects | Cheat Sheet


Object

An Object is a collection of properties.

A property is an association between a name


(or key) and a value.

For example, a person has a name, age, city,


etc. These are the properties of the person.

Key Value

firstName Rahul

lastName Attuluri

age 28

city Delhi

1. Creating an Object

We can add properties into

{} as key: value pairs.


JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 };
6
7 console.log(person); // O

1.1 Identifiers

A valid Identifier should follow the below


rules:

It can contain alphanumeric


characters, _ and $ .

It cannot start with a number.

Valid Identifiers:
JAVASCRIPT

1 firstName;
2 $firstName;
3 firstName;
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=2a65b1b9-f… 1/7
8/30/23, 6:51 AM Revolutionizing the Job Market | NxtWave
3 _firstName;
4 firstName12;

Invalid Identifiers:
JAVASCRIPT

1 12firstName;
2 firstName 12;

To use an Invalid identifier as a key, we have


to specify it in quotes.
JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 "1": "value1",
6 "my choice": "value2",
7 };
8
9 console.log(person); // O

2. Accessing Object Properties

2.1 Dot Notation


JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 "1": "value1",
6 "my choice": "value2",
7 };
8
9 console.log(person.firstNa

Use Dot notation when the key is a valid


Identifier.

2.2 Bracket Notation


JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 "1": "value1",
6 "my choice": "value2",
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=2a65b1b9-f… 2/7
8/30/23, 6:51 AM Revolutionizing the Job Market | NxtWave

7 };
8
9 console.log(person["firstN

2.3 Accessing Non-existent Properties

Dot Notation:
JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 "1": "value1",
6 "my choice": "value2",
7 };
8
9 console.log(person.gender)

Bracket Notation:
JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 "1": "value1",
6 "my choice": "value2",
7 };
8
9 console.log(person["gender

2.4 Variable as a Key


JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 };
6
7 let a = "firstName";
8
9 console.log(person[a]);
10
Expand

2.5 Object Destructuring

To unpack properties from Objects, we use


Object Destructuring. The variable name

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=2a65b1b9-f… 3/7
8/30/23, 6:51 AM Revolutionizing the Job Market | NxtWave

should match with the key of an object.


JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 };
6
7 let { gender, age } = p
8
9 console.log(gender); /
10
Expand

Try out creating and accessing the Object in


different ways like Object destructuring, dot
notation etc. in the below Code Playground.

HTML CSS JAVASCRIPT

1 <!DOCTYPE html>
2 <html>
3 <head></head>
4 <body>
5 Your HTML code goes here. W
6 </body>
7 </html>

3. Modifying Objects

3.1 Modifying Object Property

Dot Notation:
JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=2a65b1b9-f… 4/7
8/30/23, 6:51 AM Revolutionizing the Job Market | NxtWave
4 age: 28,
5 };
6
7 person.firstName = "Abhi";
8
9 console.log(person.firstNa

Bracket Notation:
JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 };
6
7 person["firstName"] = "Abh
8
9 console.log(person["firstN

3.2 Adding Object Property

Dot Notation:
JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 };
6
7 person.gender = "Male";
8
9 console.log(person); // O

Bracket Notation:
JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 };
6
7 person["gender"] = "Male";
8
9 console.log(person); // O

4. Property Value
The Value of Object Property can be

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=2a65b1b9-f… 5/7
8/30/23, 6:51 AM Revolutionizing the Job Market | NxtWave

Function

Array

Object

4.1 Function as a Value


JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 run: function () {
6 console.log("Start Ru
7 },
8 };
9
10 person.run(); // Start R

Methods:

A JavaScript method is a property containing


a function definition.

For example, in

document.createElement(); , the
document is an Object, createElement
is a key and createElement() is a Method.

4.2 Array as a Value


JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 habits: ["Playing Che
6 };
7
8 console.log(person.habi
9
10 console.log(person.habi

Expand

4.3 Object as a Value


JAVASCRIPT

1 let person = {
2 firstName: "Rahul",
3 lastName: "Attuluri",
4 age: 28,
5 habits: ["Playing Che
6 car: {
https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=2a65b1b9-f… 6/7
8/30/23, 6:51 AM Revolutionizing the Job Market | NxtWave

7 name: "Audi",
8 model: "A6",
9 color: "White",
10 },

Expand

HTML CSS JAVASCRIPT

1 <!DOCTYPE html>
2 <html>
3 <head></head>
4 <body>
5 Your HTML code goes here. W
6 </body>
7 </html>

https://learning.ccbp.in/course?c_id=5e93210e-f183-433d-a12d-79d81deb01be&t_id=79fb8730-bdad-4ef8-a1ea-7e79d207fd8b&s_id=2a65b1b9-f… 7/7

You might also like