Skip to content

Instantly share code, notes, and snippets.

View HassanAlgoz's full-sized avatar

Hassan Algoz HassanAlgoz

View GitHub Profile
// Object refers to a data structure containing data and/or instructions (functions).
// Object Lateral: key-value pairs
let dictionary = {
'hello': "مرحباً",
'good morning': "صباح الخير",
translateWord(english_word) {
let word = english_word.toLowerCase()
// useful link: https://www.w3schools.com/js/js_datatypes.asp
typeof "Hello" // string
typeof 'a' // string
typeof 7 // number
typeof 3.141 // number
typeof true // boolean
typeof undefined // undefined
typeof {name: "Ahmad", age: 99} // object
typeof console // object
typeof console.log // function
let hybrid = [1, 2, 3, "hello", "abc", 4, 5, 6]
console.log(hybrid.length)
let fruits = ["Strawberry", "Apple", "Mango", "Banana"]
console.log( fruits.sort())
console.log( fruits[0])
console.log( fruits[fruits.length - 1])
let str = fruits[0]
console.log(str.charAt(0) === str[0]) // array-like (but not really array)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tab Title</title>
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="styles.css">
</head>
<body>