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', 'Albania',
'Bolivia', 'Bolivia',
'Canada', 'Canada',
@ -10,4 +13,6 @@ const countries = [
'Ireland', 'Ireland',
'Japan', 'Japan',
'Kenya', '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 text = 'I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.'
let new_array = [] let new_array = []
let new_element = "" let new_element = ""
for(let x in text) for(let x in text)
{ {
if(text[x] == " ") if(text[x] == " " || text[x] == ".")
{ {
new_array.push(new_element) new_array.push(new_element)
new_element = "" new_element = ""
@ -13,4 +14,37 @@ for(let x in text)
} }
} }
console.log(new_array.length) 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', 'HTML',
'CSS', 'CSS',
'JavaScript', 'JavaScript',
@ -6,4 +8,6 @@ const webTechs = [
'Redux', 'Redux',
'Node', 'Node',
'MongoDB', 'MongoDB',
] ]
return webTechs
}

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