DEV Community

hex-paradus
hex-paradus

Posted on • Edited on

Section 01: JavaScript Fundamentals

<!DOCTYPE html>





JavaScript Fundamentals – Part 1
<br> body {<br> height: 100vh;<br> display: flex;<br> align-items: center;<br> background: linear-gradient(to top left, #28b487, #7dd56f);<br> }</p> <div class="highlight"><pre class="highlight plaintext"><code>h1 { font-family: sans-serif; font-size: 50px; line-height: 1.3; width: 100%; padding: 30px; text-align: center; color: white; } </code></pre></div> <p>

I AM SORRY :(.




//Assingment1
/*
let country = "Bangladesh";
let continent = "Asia";
let population = "20 Million";
console.log(country);
console.log(continent);
console.log(population);

//Assigment2

//let isIsland = false;
// let language;
// console.log(typeof country)
// console.log(typeof continent)
// console.log(typeof population)
// console.log(typeof language)
// console.log(typeof isIsland)

//Assingment3
let language;
language="Bangla"
let population=200000000
const country="Bangladesh"
const continent="Asia"
const isIsland=false
//isIsland=true
//Assigment4
let countryFirstHalf=population/2
let countrySecondHalf=population/2
console.log(population+1)
let finlandPopulation=6000000
console.log(population>finlandPopulation)
let averagePopulation=33000000
console.log(population<averagePopulation)
let description=(country+" is in "+continent+", and its "+population/1000000+" million people speak "+language)
console.log(description)
//Assingment5
description= ${country} is in ${continent}, and its ${population/1000000} million people speak ${language} language.
console.log(description)

//Assingment6
if (population>33){
console.log("Portugal's population is above average")
} else {
console.log(Portugal's population is ${33-population} million below average)
}

//Assingement6
// numNeighbours=Number(prompt(How many neighbour countries does your country have?))
// if (numNeighbours===1){
// console.log(Only 1 border.)
// }else if (numNeighbours>1) {
// console.log(More than 1 border.)
// }else {
// console.log(No borders.)
// }

//Assingment7
if (language==="English" && !population<5000000 && !isIsland){ // Double == has inbuult type coercion but === does not have it
console.log(You should live in ${country} :).)
}else {
console.log(${country} does not meet your criteria :(.)
}

//Assingment8
language=Chinese or Mandarin;

switch (language) {
case "Chinese or Mandarin":
console.log(Most number of native speakers!)
break
case Spanish:
console.log(2nd place in number of native speakers.)
break
case English:
console.log(3rd place.)
break
case Hindi:
console.log(Number 4.)
break
case Arabic:
console.log(5th most spoken language.)
break
default:
console.log(Great language too :D.)
}
//Assingment9
let population=200

// population>33 ? console.log(Portugal's population is above average.): console.log(Portugal's population is below average.)

//It's actually used like this
console.log(Bangladesh's population is ${population>33 ? 'above':'below'} average)
*/

/*
//CodingChallenge1
let markMass=78
let markHeight=1.69
let johnMass=92
let johnHeight=1.95
let markMass=95
let markHeight=1.88
let johnMass=85
let johnHeight=1.76

let markBMI= markMass/(markHeight **2)
let johnBMI= johnMass/(johnHeight **2)
console.log(markBMI,johnBMI)
const markHigherBMI=(markBMI>johnBMI)
console.log(markHigherBMI)
//CodingChallenge2
if(markBMI>johnBMI){
console.log(Mark's BMI(${markBMI}) is higher than Johns!(${johnBMI}))}
else{
console.log(John's BMI(${johnBMI}) is higher than Mark!(${markBMI}))}

//CodingChallenge3
dolphinsMatch1=97
dolphinsMatch2=112
dolphinsMatch3=101
koalasMatch1=109
koalasMatch2=95
koalasMatch3=106

dolphinsAverage=(dolphinsMatch1+dolphinsMatch2
+dolphinsMatch3)/3
koalasAverage=(koalasMatch1+koalasMatch2+koalasMatch3)/3
console.log("Dolphins average = "+dolphinsAverage)
console.log("Koalas Average = "+koalasAverage)
if (dolphinsAverage>koalasAverage && dolphinsAverage>100){
console.log(Dolphins are the winner!)
}else if (dolphinsAverage===koalasAverage && dolphinsAverage>=100 && koalasAverage>=100){
console.log(The match is a draw!)
}
else if (koalasAverage>dolphinsAverage && koalasAverage>100){
console.log(Koalas are the winner!)
}else{
console.log(There is no winner :(.)
}
*/
//CodingChallenge4
let bill =40
let tip = 50<bill && bill<300 ? (.15*bill):(.20*bill)
console.log(The bill was ${bill}, the tip was ${tip} and the total value was ${bill+tip})

Top comments (0)