0% found this document useful (0 votes)
26 views

JavaScript Notes

Uploaded by

Mircella
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

JavaScript Notes

Uploaded by

Mircella
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

JavaScript

confirm(); -всплывающее окно подтверждения


Пример

prompt(); - всплывающее окно, запрашивающее информацию

Variables
// Here is an example of using the greater than (>) operator.
console.log(15 > 4); // 15 > 4 evaluates to true, so true is printed.

// Fill in with >, <, === so that the following print out true:
console.log("Xiao Hui".length < 122);
console.log("Goody Donaldson".length >= 8);
console.log(8*2 === 16);
Output
true
true
true
true
Decisions, decisions
if statement
if( "myName".length >= 7 ) {
console.log("You have a long name!");
}

if-else statement
if( "myName".length >= 7 ) {
console.log("You have a long name!");
}
else {
console.log("You have a short name!");
Substrings
"some word".substring(x, y)
x is where you start chopping
y is where you finish chopping
Example
“hello”.substring(0,2);
0 1 2 3 4
| | | | |
h e l l o
The letter h is in position 0, the letter e is in position 1, and so on.
Output
he
Example
“Batman”.substring(0,3); - first 3 letters
Output
Bat
“laptop”.substring(3,6); - from 4th to 6th letter
Output
top

You might also like