completed some more exercises

pull/285/head
Chervix 3 years ago
parent e71be9005b
commit a36a835065

@ -1,4 +1,7 @@
const countries = [
export function country()
{
const countries = [
'Albania',
'Bolivia',
'Canada',
@ -10,4 +13,6 @@ const countries = [
'Ireland',
'Japan',
'Kenya',
]
]
return countries
}

@ -1,10 +1,11 @@
import { web_tech } from "./webtechs"
let text = 'I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.'
let new_array = []
let new_element = ""
for(let x in text)
{
if(text[x] == " ")
if(text[x] == " " || text[x] == ".")
{
new_array.push(new_element)
new_element = ""
@ -13,4 +14,37 @@ for(let x in text)
}
}
console.log(new_array.length)
console.log(new_array)
console.log(new_array) //2
let shopping_cart = ["Milk", "Coffee", "Tea", "Honey"]
if(shopping_cart[0] != "Meat")
{
shopping_cart.splice(0, 0, "Meat")
}
if(shopping_cart[shopping_cart.length - 1] != "sugar")
{
shopping_cart.splice(shopping_cart.length - 1, 0, "Sugar")
}
let like_honey = false
if(like_honey == false)
{
shopping_cart.splice(shopping_cart.length - 1, 1)
}
shopping_cart[3] = "Green Tea"
console.log(shopping_cart) //3
console.log("untested")
let found = false
for(let i in countries)
{
if(countries[i] == "Ethiopia")
{
console.log("ETHIOPIA")
found = true
}
}
if(found == false)
{
countries.push("Ethiopia")
}
console.log(countries) //4

@ -1,4 +1,6 @@
const webTechs = [
export function web_tech()
{
const webTechs = [
'HTML',
'CSS',
'JavaScript',
@ -6,4 +8,6 @@ const webTechs = [
'Redux',
'Node',
'MongoDB',
]
]
return webTechs
}

@ -5,6 +5,6 @@
</head>
<body>
I am new to javascript. I hope this works
<script src ="main.js"></script>
<script src ="./exercise_02/main.js"></script>
</body>
</html>
Loading…
Cancel
Save