Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions 02_Day_Data_types/02_day_starter/index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>30DaysOfJavaScript</title>
</head>

<body>
<h1>30DaysOfJavaScript:02 Day</h1>
<h2>Data types</h2>

<!-- import your scripts here -->
<script src="./main.js"></script>

</body>

</html>
<head>
<title>30DaysOfJavaScript</title>
</head>

<body>
<h1>30DaysOfJavaScript:02 Day</h1>
<h2>Data types</h2>

<!-- import your scripts here -->
<script src="./main.js"></script>
</body>
</html>
64 changes: 63 additions & 1 deletion 02_Day_Data_types/02_day_starter/main.js
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
// this is your main.js script
//Task1-medium
console.log(
"The quote 'There is no exercise better for the heart than reaching down and lifting people up.' by John Holmes teaches us to help one another."
)

//Task2-medium
console.log(
'"Love is not patronizing and charity isn\'t about pity, it is about love. Charity and love are the same -- with charity you give love, so don\'t just give money but reach out your hand instead." is a quote by Mother Teresa'
)

//Task3-medium
console.log(typeof '10' == typeof 10)
console.log(typeof '10' == typeof '10')

//Task4-medium
console.log(parseFloat('9.8') == 10)
console.log(Math.round(parseFloat('9.8')) == 10)

//Task5-medium
console.log('python'.includes('on'))
console.log('jargon'.includes('on'))

//Task6-medium
console.log('I hope this course is not full of jargon.'.includes('jargon'))

//Task7-medium
console.log(Math.floor(Math.random() * 101))

//Task8-medium
console.log(Math.floor(Math.random() * 51) + 50)

//Task9-medium
console.log(Math.floor(Math.random() * 256))

//Task10-medium
let string = 'JavaScript'
let num = []
let characters = []
let rand

while (num.length < string.length) {
rand = parseInt(Math.random() * (string.length - 2))
if (!num.includes(rand)) {
num.push(rand)
}
}

for (const i of num) {
characters.push(string[i])
}

console.log(characters)

//Task11-medium
console.log('1 1 1 1 1 \n2 1 2 4 8 \n3 1 3 9 27 \n4 1 4 16 64 \n5 1 5 25 125')

//Task12-medium
console.log(
'You cannot end a sentence with because because because is a conjunction'.substr(
31,
24
)
)
27 changes: 12 additions & 15 deletions 03_Day_Booleans_operators_date/03_day_starter/index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>30DaysOfJavaScript: 03 Day</title>
</head>

<body>
<h1>30DaysOfJavaScript:03 Day</h1>
<h2>Booleans, undefined, null, date object</h2>

<!-- import your scripts here -->
<script src="./scripts/main.js"></script>

</body>

</html>
<head>
<title>30DaysOfJavaScript: 03 Day</title>
</head>

<body>
<h1>30DaysOfJavaScript:03 Day</h1>
<h2>Booleans, undefined, null, date object</h2>

<!-- import your scripts here -->
<script src="./scripts/main.js"></script>
</body>
</html>
151 changes: 150 additions & 1 deletion 03_Day_Booleans_operators_date/03_day_starter/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1 +1,150 @@
// this is your main.js script
// //Task1-medium
let base = prompt('Enter base: ')
let height = prompt('Enter height: ')

let area = 0.5 * base * height

console.log(`The area of the triangle is ${area}`)

// //Task2-medium
let a = parseFloat(prompt('Enter side a: '))
let b = parseFloat(prompt('Enter side b: '))
let c = parseFloat(prompt('Enter side c: '))

let P = a + b + c

console.log(`The area of the triangle is ${P}`)

// //Task3-medium
let length = prompt('Enter length: ')
let width = prompt('Enter width: ')

area = length * width
P = 2 * (length + width)

console.log(`The area of the rectangle is ${area}.`)
console.log(`The perimeter of the rectangle is ${P}.`)

// //Task4-medium
let radius = prompt('Enter radius: ')
pi = 3.14

area = pi * radius * radius
let C = 2 * pi * radius

console.log(`The area of the circle is ${area}`)
console.log(`The circumference of the circle is ${C}`)

//Task5-mediums
//y = 2x - 2
let slope = 2
let xIntercept = [slope / 2, 0]
let yIntercept = [0, 2]

console.log(slope, xIntercept, yIntercept)

//Task6-medium
let point1 = '(2, 2)'
let point2 = '(6, 10)'

let comma1 = point1.indexOf(',')
let comma2 = point2.indexOf(',')

let x1 = parseFloat(point1.substring(1, comma1))
let y1 = parseFloat(point1.substring(comma1 + 1))
let x2 = parseFloat(point2.substring(1, comma2))
let y2 = parseFloat(point2.substring(comma2 + 1))

let m = (y2 - y1) / (x2 - x1)

console.log(m)

//Task7-medium
point1 = prompt('Enter the first point: ')
point2 = prompt('Enter the second point: ')

x1 = parseFloat(point1.substring(1, comma1))
y1 = parseFloat(point1.substring(comma1 + 1))
x2 = parseFloat(point2.substring(1, comma2))
y2 = parseFloat(point2.substring(comma2 + 1))

m = (y2 - y1) / (x2 - x1)

console.log(m)

// //Task8-medium
x = 2
y = x * x + 6 * x + 9
let y0 = 0

x = -6 / 2

console.log(y)
console.log(x)

// //Task9-medium
let hours = prompt('Enter hours: ')
let rate = prompt('Enter rate per hour: ')

let earning = hours * rate

console.log(`Your weekly earning is ${earning}`)

//Task10-medium
let name = 'Arina'
let isLong = name.length > 7

isLong ? console.log('My name is long') : console.log('My name is short')

//Task11-medium
firstName = 'Asabeneh'
lastName = 'Yetayeh'

let isLonger = firstName.length > lastName

isLonger
? console.log(
`Your first name, ${firstName} is longer than your family name, ${lastName}`
)
: console.log(
`Your first name, ${firstName} is shorter than your family name, ${lastName}`
)

//Task12-medium
let myAge = 250
let yourAge = 25

myAge > yourAge
? console.log(`I am ${myAge - yourAge} yeats older than you.`)
: console.log(`You are ${yourAge - myAge} yeats older than me.`)

// //Task13-medium
let birthYear = parseInt(prompt('Enter your birth year: '))
let currentYear = new Date().getFullYear()
age = currentYear - birthYear

age > 18
? console.log(`You are ${age}. You are old enough to drive.`)
: console.log(
`You are ${age}. You will be allowed to drive after ${18 - age} years.`
)

//Task14-medium
age = prompt('Enter number of years you live: ')

let ageSeconds = age * 365 * 24 * 60 * 60

console.log(ageSeconds)

//Task15-medium
const now = new Date()

const year = now.getFullYear()
const month = now.getMonth()
const nowDate = now.getDate()
const nowHours = now.getHours()
const minutes = now.getMinutes()

console.log(`${year}-${month}-${nowDate} ${nowHours}:${minutes}`)
console.log(`${nowDate}-${month}-${year} ${nowHours}:${minutes}`)
console.log(`${nowDate}/${month}/${year} ${nowHours}:${minutes}`)
27 changes: 12 additions & 15 deletions 09_Day_Higher_order_functions/09_day_starter/index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>30DaysOfJavaScript:09 Day </title>
</head>

<body>
<h1>30DaysOfJavaScript:09 Day</h1>
<h2>Functional Programming</h2>

<script src="./data/countries_data.js"></script>
<script src="./scripts/main.js"></script>

</body>

</html>
<head>
<title>30DaysOfJavaScript:09 Day</title>
</head>

<body>
<h1>30DaysOfJavaScript:09 Day</h1>
<h2>Functional Programming</h2>

<script src="./data/countries_data.js"></script>
<script src="./scripts/main.js"></script>
</body>
</html>
Loading