0
0
Javascriptprogramming~10 mins

Arrow functions in Javascript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create an arrow function that adds two numbers.

Javascript
const add = (a, b) => [1];
Drag options to blanks, or click blank then click option'
Aa * b
Ba + b
Ca - b
Da / b
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
Forgetting to include both parameters.
2fill in blank
medium

Complete the code to create an arrow function that returns the square of a number.

Javascript
const square = x => [1];
Drag options to blanks, or click blank then click option'
Ax * x
Bx + x
Cx / 2
Dx - 1
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Adding the number to itself instead of multiplying.
Dividing or subtracting instead of multiplying.
3fill in blank
hard

Fix the error in the arrow function that returns the length of a string.

Javascript
const length = str => [1];
Drag options to blanks, or click blank then click option'
Astr.length
Bstr.length()
Clength(str)
Dstr.size
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using parentheses after length like a function call.
Using incorrect property names like size.
4fill in blank
hard

Fill both blanks to create an arrow function that filters an array for numbers greater than 10.

Javascript
const filterLarge = arr => arr.filter(num => num [1] [2]);
Drag options to blanks, or click blank then click option'
A>
B10
C<
D5
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using '<' instead of '>' for the comparison.
Using the wrong number for comparison.
5fill in blank
hard

Fill all three blanks to create an arrow function that maps an array to uppercase strings and filters those starting with 'A'.

Javascript
const process = arr => arr.map(str => str.[1]()).filter(str => str.[2](0) === [3]);
Drag options to blanks, or click blank then click option'
AtoUpperCase
BcharAt
C'A'
DtoLowerCase
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using 'toLowerCase' instead of 'toUpperCase'.
Using incorrect methods to get the first character.
Comparing to the wrong character.