```js
// Data types and console logging
const myName = 'Sohaib';
let age = 50;
console.log('Hello! My name is ' + myName + ' and my age is ' + age + '\n');
// String Manipulation
const randomString1 = 'Hello ';
const randomString2 = 'World';
console.log(`Joining 2 random Strings: ${ randomString1 + randomString2 }\n`);
// Arrays and loops
let numberList = [1, 2, 3, 4, 5];
let stringList = ['a', 'b', 'c', 'd', 'e'];
console.log(`Multiplying 2 numbers from numberList: ${ numberList[1] * numberList[2] }\n`);
console.log(`Adding 2 strings from stringList: ${ stringList[1] + stringList[2] }\n`);
let sum = 0;
for (num in numberList) {
sum += Number(num); // sum = sum + num;
}
console.log(`Sum of all numbers in numberList: ${ sum }\n`);
// Functions
// Standard Function
function addTwoNumbers(num1, num2) {
return num1 + num2;
}
// Big Arrow Function / variable definition
let addThreeNumbers = (num1, num2, num3) => {
return num1 + num2 + num3;
}
console.log(`Calling first function: ${ addTwoNumbers(5, 10) }\n`);
console.log(`Calling second function: ${ addThreeNumbers(5, 10, 15) }\n`);
// Classes and Objects
// Person Class
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
getDetails() {
return `Name: ${ this.name }, Age: ${ this.age }`;
}
}
let personList = [];
let john = new Person('John', 25);
let jane = new Person('Jane', 30);
let jack = new Person('Jack', 35);
let jill = new Person('Jill', 40);
personList.push(john);
personList.push(jane);
personList.push(jack);
personList.push(jill);
for (person of personList) {
console.log(person.getDetails());
}
```