Skip to content
Merged
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
14 changes: 7 additions & 7 deletions js/level1.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
Example:
var hello = 'Hello World';
alert(hello);
It will pop-up alert box with string 'Hello World!'
It will pop-up an alert box with string 'Hello World!'
*/

//TODO: Create 2 variables, 1 with your name and 2nd with your age and display them with alert pop-up box
Expand All @@ -71,28 +71,28 @@


/* Arithmetic operators
There is a bunch of different operators in programming. We will look through arithmetical operators now.
There are a bunch of different operators in programming. We will look through arithmetical operators now.
They are standard arithmetical operators (+, -, /, *, etc) that you can use to do math with your numbers.
Example:
var sumOfNumbers = 1 + 3;
alert(sumOfNumbers);
It will pop-up alert box with number 4
*/

//TODO: Create 3 variables, 1st variable named ten with value 10 inside, 2nd variable named three with value 3. And finally 3d variable named multipleOfNumbers that will be equal 1st variable multiply by 2nd variable. And in the end console or alert value of multipleOfNumbers
//TODO: Create 3 variables, 1st variable named ten with value 10 inside, 2nd variable named three with value 3. And finally 3rd variable named multipleOfNumbers that will be equal to 1st variable multiplied by the 2nd variable. And in the end display the value of multipleOfNumbers





/* Functions
Function is a separable, reusable piece of code. Some action that you want to do. It takes some input(arguments), do some manipulation
on it and return the output with key-word 'return'.
on it and returns the output with key-word 'return'.
To create a function you need do following:
var functionName = function(argument){
return argument * 2;
};
So, our function will take 1 argument and return argument multiplied by 2. But for now it will do nothing as we need to call for our function.
So, our function will take 1 argument and return argument multiplied by 2. But for now it will do nothing as we need to call our function.
To call the function we do so:
functionName(10);
Now we will call our function with argument that is 10. And our function will return us 20. To see what our function
Expand All @@ -101,7 +101,7 @@

//TODO: It's your turn to create a function.
//Step 1 - Name it 'add' and pass in two argumnets (num1 and num2).
//Step 2 - This function should return us a summ of num1 and num2.
//Step 2 - This function should return us a sum of num1 and num2.
//Step 3 - Call the function with numbers 2 and 3. To see result you can alert it or console.log it - to be sure that it works right.


Expand Down Expand Up @@ -141,7 +141,7 @@

/*Comparison operators
You remember we were talking about arithmetical operators and that we have different operators in programming, so
here comes time to introduce you comparison operators that we can use to compare values(>, <, <=, =>, ==, !=).
here comes time to introduce you to comparison operators that are used to compare values(>, <, <=, =>, ==, !=).
Most of them you know from math classes in school, some of them can be new for you, so '==' is checking equality, if two values are equal.
'!=' - checks if they are not equal.
PS: Don't mix up '=' and '==' as they have different meaning.
Expand Down
30 changes: 17 additions & 13 deletions js/level2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//Level2

/* Arrays
It is ordered list of values. It can keep any number of values inside. And also
It is an ordered list of values. It can keep any number of values inside. And also
any type of values - numbers, strings, objects.
Example:
var animals = ['cat', 'dog', 'horse];
Expand Down Expand Up @@ -40,7 +40,7 @@
var secondItem = randomThings[1]; and so on
*/

//TODO: get 3d element from your array favouriteFood and console.log it
//TODO: get 3rd element from your array favouriteFood and console.log it



Expand All @@ -52,14 +52,15 @@
We also can replace values inside of the arrays by assigning specific item from
the array to a new value.
Example:
var animals = ['cat', 'dog', 'horse];
var animals = ['cat', 'dog', 'horse'];
//let's replace 'dog' with 'fish'
animals[1] = 'fish';
//now our animals array will be ['cat', 'fish', 'horse]
//now our animals array will be ['cat', 'fish', 'horse']
*/

//TODO: take your array favouriteFood and replace first value with anything else.
//console.log whole array to check
// Dont forget, that index position starts with 0



Expand All @@ -71,12 +72,13 @@
If you want to add new value to array you can use property of array named '.push'.
It will add value to the end of the array
Example:
var animals = ['cat', 'dog', 'horse];
var animals = ['cat', 'dog', 'horse'];
animals.push('rabbit');
so now our array will be ['cat', 'dog', 'horse','rabbit']
*/

//TODO: let's extend your list of favouriteFood and add one more value in it.
//console.log list of your food o check
//console.log list of your favouriteFood and check



Expand All @@ -86,17 +88,19 @@


/* Loops
People always have been lazy and it was moving progress forward. We don't like repeat
same boring actions again and again, so we are looking for the way how to improve it.
People always have been lazy and it was moving progress forward. We don't like to repeat
same boring actions again and again, so we are looking for ways how to improve it.
Programming is the same - for example, if I want to print 'JavaScript is awesome!' 10
times what are my options? Of course, I can print 10 lines of code repeating same
phrase over and over again, but I also can tell computer to do it instead of me.
To do it we have loops.
phrase over and over again, but I also can tell computer to repeat it instead of me.
For this we have loops.
Each loop should have 3 main things:
- starting point
- condition (finishing point)
- counter (a step)
If you miss one of them you can get into infinite loop!!!

Let's look into different looping structures
*/


Expand Down Expand Up @@ -129,7 +133,7 @@
PS: i++ is a short from 'i = i + 1'
*/

//TODO: now, let's print every 3d number from 3 to 22 using 'for loop'
//TODO: now, let's print every 3rd number from 3 to 22 using 'for loop'



Expand Down Expand Up @@ -175,8 +179,8 @@
*/

//TODO: Time has come for a classic exercise - 'FizzBuzz'. Count from 1 to 50 and print
// numbers out. If number multiple of 3 print 'Fizz', if multiple of 5 - 'Buzz', if
// it is multiple of 3 and 5 - 'FizzBuzz'.
// numbers out. If number is a multiple of 3 print 'Fizz', if its a multiple of 5 print 'Buzz', if
// it is multiple of 3 and 5 print 'FizzBuzz', for everthing else print the number itself.
//PS: you can use arithmetic operator modulo (%) - it is remainder when dividing.
//10 % 3 = 1 - so in 10 we have 3*3 + 1
//16 % 4 = 0 - as in 16 we have 4*4
Expand Down