# Coding exercise for Javascript
# Part 1
## 1. Assign variable and Int/Float
- Print the constant number 3.14
- Print the constant string "Hello"
- Assign the constant value 3.14 to variable a
- Display the value of the variable a
- Assign the constant value "Hello" to variable b
- Create a new variable name cat_fur and assign it with the value 'black'
- How to show the type of a variable
- Convert int to float/float to int
- Assign the value 5 to the variable named score
- Increase score by 1
- Find the remainder when divide 129 by 7
- CHALLENGE: Given a three-digit number. Find the sum of its digits.
## 2. String
text = 'CODERSCHOOL'
- Choose the character at index 5
- Try to assign a new character to the index 5 character
- Choose only the 'SCHOOL' part
- Print string backward
- Concatenate 2 string
## 3. Boolean
a=1,b=3
- Compare a and b
- Operation on boolean, example: True + False + True
## 4. Condition
- Write a program that:
Create a variable named numberOfCats, and assign a number to it.
If the number of cats is 0, message "Cat is cute, get one!"
If the number of cats is 1, message "Lonely!"
If the number of cats above 1 to under 5, message "Happy family"
From 5 and above, "Are cats going to rule the world?"
- Given 2 numbers, find the largest number
- Given 3 numbers, find the smallest number
## 5. Function
- Write a function to sum two number
- Discuss global and local variable in a function
- Write a function that: Given 2 numbers, find the largest number
- Write another function that: Given 3 numbers, find the smallest number
- CHALLENGE: Write a function that checks whether a passed string is palindrome or not.
## 6. For/while loop
- Write a loop that print out numbers between 0 and 10. Try to write it by using either 'for' or 'while'
- For that same problem, write a loop to calculate the sum of all numbers you have printed out
- Write a function to calculate the factorial of a number
- CHALLENGE: (nested for loops) Given a number n, write a function to print out the following:
1
2 2
3 3 3
4 4 4 4
...
n n n n ... n
For example, if n = 5, then your function should print out:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
# Part 2
## 1. Array
- Create an empty array
- Create an array to store fruits name
- Create an array to store different datatype values
- Create an array inside another array
- Indexing and slicing
- Append an item to array
- Push/pop an item from an array
- Remove an item
- Return index of an item
- Convert a string into an array
- CHALLENGE: Create an array of 10 random positive integer numbers, print the index/indices of even numbers
- CHALLENGE: Given an array of distinct numbers, swap the minimum numbers and the maximum numbers and print the resulting array.
## 2. Object (Dictionary)
- Create an object of your choice
- Create a nested object
- Access a value of your object using its property
- Edit a value of your object
- Add a new property to your object
- Return an array of properties
- Return an array of values
- CHALLENGE: Given a dictionary that record the test score of a student. Write a function that:
Take in the parameter of the score report and a subject name.
Check if the student took the test in that subject, if yes, return the score.
report = {"Nhan": {'Biology': 9,
'Chemistry': 8,
'Maths': 1}}