0% found this document useful (0 votes)
7 views4 pages

INput Element and Mathfuntion

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)
7 views4 pages

INput Element and Mathfuntion

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/ 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

You might also like