3. Coding Challenge Flashcards
LECTURE: Values and Variables
- Declare variables called ‘country’, ‘continent’ and ‘population’ and
assign their values according to your own country (population in millions) - Log their values to the console
let country = 'India'; let continent = 'Asia'; let population = 135; console.log(country); console.log(continent); console.log(population);
LECTURE: Data Types
- Declare a variable called ‘isIsland’ and set its value according to your
country. The variable should hold a Boolean value. Also declare a variable.
‘language’, but don’t assign it any value yet - Log the types(TYPEOF) of ‘isIsland’, ‘population’, ‘country’ and ‘language’
to the console
let isIsland = false; let language; console.log(typeof isIsland); console.log(typeof population); console.log(typeof country); console.log(typeof language);
LECTURE: let, const and var
- Set the value of ‘language’ to the language spoken where you live (some
countries have multiple languages, but just choose one) - Think about which variables should be const variables (which values will never change, and which might change?). Then, change these variables to const.
- Try to change one of the changed variables now, and observe what happens
language = 'portuguese'; const country = 'Portugal'; const continent = 'Europe'; const isIsland = false; isIsland = true;
LECTURE: Basic Operators
If your country split in half, and each half would contain half the population,
then how many people would live in each half?
2. Increase the population of your country by 1 and log the result to the console
3. Finland has a population of 6 million. Does your country have more people than Finland?
4. The average population of a country is 33 million people. Does your country
have less people than the average country?
5. Based on the variables you created, create a new variable ‘description’
which contains a string with this format: ‘Portugal is in Europe, and its 11 million
people speak portuguese’
console.log(population / 2); population++; console.log(population); console.log(population > 6); console.log(population < 33); const description1 = country + ' is in ' + continent + ', and its ' + population + ' million people speak ' + language; console.log(description1);