Skip to content

Commit 35714af

Browse files
committed
Finished 01-0
1 parent 955a910 commit 35714af

File tree

2 files changed

+54
-30
lines changed

2 files changed

+54
-30
lines changed

package-lock.json

+22-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/01-0-basics.js

+32-8
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,75 @@
33
*/
44

55
// 1. Define three string variables firstName, middleName, and lastName.
6+
var firstName = "Jeff";
7+
var middleName = "Keegan";
8+
var lastName = "Leary";
69

710
// 2. Declare a function named logFullName that takes no arguments.
811
function logFullName() {
9-
// 3. Using template literals, create another variable fullName that combines all three names.
10-
// 4. Print the fullName to the console.
12+
var fullName = `${firstName} ${middleName} ${lastName}`;
13+
console.log(fullName);
1114
}
1215

1316
/**
1417
* Task 2: Data Types
1518
*/
1619

1720
// 1. Declare a variable named age and assign it a number.
21+
var age = 29;
1822
// 2. Declare a variable named isStudent and assign it a boolean value.
23+
var isStudent = true;
1924
// 3. Declare a variable named courses and assign it an array containing three string values representing courses e.g. "Math", "Science", "History".
25+
var courses = ["Math", "Science", "History"];
2026

2127
// 4. Declare a function named logVariableTypes that takes no arguments.
2228
function logVariableTypes() {
23-
// 5. Print the type of each variable using the typeof operator.
29+
// 5. Print the type of each variable using the typeof operator.
30+
console.log(typeof age);
31+
console.log(typeof isStudent);
32+
console.log(typeof courses);
2433
}
2534

2635
/**
2736
* Task 3: Variables Declaration
2837
*/
2938

3039
// 1. Using var, declare a variable named school and assign it a value of "Hogwarts".
40+
var school = "Hogwarts";
3141
// 2. Using let, declare a variable named subject and assign it a value of "Potions".
42+
let subject = "Potions";
3243
// 3. Using const, declare a variable named professor and assign it a value of "Snape".
44+
const professor = "Snape";
3345

3446
/**
3547
* Task 4: Basic Operators
3648
*/
3749

3850
// 1. Declare two variables x and y with values 5 and 10 respectively.
51+
const x = 5;
52+
const y = 10;
3953

4054
function logAddition() {
41-
// 2. Log the sum of x and y.
55+
// 2. Log the sum of x and y.
56+
const sum = x + y;
57+
console.log(sum);
4258
}
4359
function logSubtraction() {
44-
// 3. Log the x subtracted from y
60+
// 3. Log the x subtracted from y
61+
const subtract = y - x;
62+
console.log(subtract);
4563
}
4664

4765
function logMultiplication() {
48-
// 4. Log the product of x and y.
66+
// 4. Log the product of x and y.
67+
const product = x * y;
68+
console.log(product);
4969
}
5070

5171
function logDivision() {
52-
// 5. Log the quotient when x is divided by y.
72+
// 5. Log the quotient when x is divided by y.
73+
const quotient = x / y;
74+
console.log(quotient);
5375
}
5476

5577
/**
@@ -63,5 +85,7 @@ let result1 = 3 + 4 * 5;
6385
let result2 = (3 + 4) * 5;
6486

6587
function logResults() {
66-
// 3. Log both result values in your JavaScript environment and check your answers.
88+
// 3. Log both result values in your JavaScript environment and check your answers.
89+
console.log(result1);
90+
console.log(result2);
6791
}

0 commit comments

Comments
 (0)