-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path00 - Hello JavaScript.js
37 lines (29 loc) · 1.27 KB
/
00 - Hello JavaScript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Line comments start with two forward slashes. Like this line.
/* Multi line comments start with a forward slash and a star,
and end with a star and a forward slash. */
// 1. number
// Variables are used to store objects, and are defined using the keyword var.
var the_answer = 42.0; //
print(the_answer);
// 2. String objects start and end with a single quote.
var my_variable = "I am a string";
print(my_variable)
// // Parentheses are used to pass parameters to functions.
// print('This string will print in the Console tab.');
// // Square brackets are used for selecting items within a list.
// // The zero index refers to the first item in the list.
var my_list = ['eggplant', 'apple', 'wheat'];
print(my_list[0]);
// // Curly brackets (or braces) can be used to define dictionaries
// // (key:value pairs).
var my_dict = {'food':'bread', 'color':'red', 'number':42};
print(my_dict.food)
// // Square brackets can be used to access dictionary items by key.
// print(my_dict['color']);
// //Or you can use the dot notation to get the same result.
// print(my_dict.color);
// // Functions can be defined as a way to reuse code and make it easier to read.
// var my_hello_function = function(string) {
// return 'Hello ' + string + '!';
// };
// print(my_hello_function('world'));