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 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>
124 changes: 122 additions & 2 deletions 09_Day_Higher_order_functions/09_day_starter/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,122 @@
console.log(countries)
alert('Open the console and check if the countries has been loaded')
const countries2 = ['Finland', 'Sweden', 'Denmark', 'Norway', 'Iceland']
const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook']
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const products = [
{ product: 'banana', price: 3 },
{ product: 'mango', price: 6 },
{ product: 'potato', price: ' ' },
{ product: 'avocado', price: 8 },
{ product: 'coffee', price: 10 },
{ product: 'tea', price: '' },
]

//Task1-easy
//Task2-easy
//Task3-easy
function callbackCountries(element) {
console.log(element)
}

countries2.forEach(callbackCountries)

//Task4-easy
names.forEach(elem => {
console.log(elem)
})

//Task5-easy
numbers.forEach(elem => {
console.log(elem)
})

//Task6-easy
const newCountries2 = countries2.map(country => country.toLocaleUpperCase())
console.log(newCountries2)

//Task7-easy
const lengthCountries2 = countries2.map(elem => elem.length)
console.log(lengthCountries2)

//Task8-easy
const numbersSqr = numbers.map(num => num * num)
console.log(numbersSqr)

//Task9easy
const namesUpperCase = names.map(name => name.toUpperCase)
console.log(namesUpperCase)

//Task10-easy
const price = products.map(
product => `Price of ${product.product} = ${product.price}`
)
console.log(price)

//Task11-easy
const countriesWithLand = countries2.filter(country => country.includes('land'))
console.log(countriesWithLand)

//Task12-easy
const countriesSix = countries2.filter(country => country.length == 6)
console.log(countriesSix)

//Task13-easy
const countriesSixAndMore = countries2.filter(country => country.length >= 6)
console.log(countriesSixAndMore)

//Task14-easy
const countriesStartsWithE = countries2.filter(country => country[0] == 'E')
console.log(countriesStartsWithE)

//Task15-easy
const priceWithValue = products.filter(
product => typeof product.price == 'number'
)
console.log(priceWithValue)

//Task16-easy
const arr = [1, 'string', 'lntlns', 'lekj', 590]

function getStringLists(array) {
const newArray = array.filter(elem => typeof elem == 'string')

return newArray
}
console.log(getStringLists(arr))

//Task17-easy
const sum = numbers.reduce((acc, cur) => acc + cur)
console.log(sum)

//Task18-easy
const countriesToString = countries2.reduce((acc, cur, index) => index != countries2.length - 1 ? acc.concat(`, ${cur}`) : acc.concat(`, and ${cur} are north European countries`))
console.log(countriesToString)

//Task19-easy
//Task20-easy
const namesLength = names.some(name => name.length > 7)
console.log(namesLength)

//Task21-easy
const countriesContainsLand = countries2.every(country =>
country.includes('land')
)
console.log(countriesContainsLand)

//Task22-easy
//Task23-easy
const countryWithSixLetters = countries2.find(country => country.length == 6)
console.log(countryWithSixLetters)

//Task24-easy
const countryWithSixLetters2 = countries2.findIndex(
country => country.length == 6
)
console.log(countryWithSixLetters2)

//Task25-easy
const norwayPosition = countries2.findIndex(country => country == 'Norway')
console.log(norwayPosition)

//Task26-easy
const russiaPosition = countries2.findIndex(country => country == 'Russia')
console.log(russiaPosition)
2 changes: 1 addition & 1 deletion 10_Day_Sets_and_Maps/10_day_starter/data/countries_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ const countries = [
},
{
name: 'United States Minor Outlying Islands',
capital: '',
capital: '',f
languages: ['English'],
population: 300,
flag: 'https://restcountries.eu/data/umi.svg',
Expand Down
65 changes: 63 additions & 2 deletions 10_Day_Sets_and_Maps/10_day_starter/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,63 @@
console.log(countries)
alert('Open the console and check if the countries has been loaded')
//Task1-easy
const empty = new Set()
console.log(empty)

//Task2-easy
const numbers = new Set()

for (let i = 0; i <= 10; i++) {
numbers.add(i)
}

console.log(numbers)

//Task3-easy
numbers.delete(1)
console.log(numbers)

//Task4-easy
numbers.clear()
console.log(numbers)

//Task5-easy
const words = ['hello', 'text', 'hello', 'plant', 'tree']

const wordsSet = new Set(words)

console.log(wordsSet)

//Task6-easy
const countries3 = ['Finland', 'Sweden', 'Norway']

const countriesMap = new Map()

for (let i = 0; i <= countries3.length - 1; i++) {
countriesMap.set(countries3[i], countries3[i].length)
}

//Task1-medium
const a = [4, 5, 8, 9]
const b = [3, 4, 5, 7]

const A = new Set(a)
const B = new Set(b)

let c = new Set([...a, ...b])

console.log(c)

//Task2-medium
c = new Set(a.filter(num => B.has(num)))
console.log(c)

//Task3-medium
c = new Set(a.filter(num => !B.has(num)))
console.log(c)

console.log(countriesMap)

//Task1-hard
console.log(countries.length)

//Task2-hard
function mostSpokenLanguages(countries, n) {}
27 changes: 12 additions & 15 deletions 11_Day_Destructuring_and_spreading/11_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:11 Day </title>
</head>

<body>
<h1>30DaysOfJavaScript:11 Day</h1>
<h2>Destructuring and Spread</h2>

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

</body>

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

<body>
<h1>30DaysOfJavaScript:11 Day</h1>
<h2>Destructuring and Spread</h2>

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