JS-A.S.A101 (Types and Coercion)
JS-A.S.A101 (Types and Coercion)
Version 1.1
Hanoi, mm/yyyy
Training Assignments Front-end Advanced Issue/Revision: x/y
RECORD OF CHANGES
Contents
Unit 1: Types and Coercion.............................................................................................................................. 4
Objectives:................................................................................................................................................ 4
Problem 01............................................................................................................................................... 4
Problem 02............................................................................................................................................... 4
Problem 03............................................................................................................................................... 4
Problem 04............................................................................................................................................... 4
CODE: JS-A.S.A101
TYPE: Medium
LOC: N/A
DURATION: 120
1. function empty(o) {
1. o = null;
2. }
3.
4. var x = [];
5. empty(x);
6. console.log(x); // ??
Problem 02
Evaluate the following code, what is the output?
1. function swap(a, b) {
2. var tmp = a;
3. a = b;
4. b = tmp;
5. }
6.
7. var x = 1;
8. var y = 2;
9.
10. swap(x, y);
11. console.log(x); // ??
Problem 03
Write a function reverse that takes a string s from snake_case to PascalCase
Example:
reverse(‘user_name’) == ‘UserName’ // true
Problem 04
Write a function mul that takes 2 numbers return the product of those 2 as string.
The first number can be very large.
The second number is from 1 to 99.
Example:
mul(123456789101112, 89) == ‘1098765422999897957’