0
0
Javascriptprogramming~10 mins

Find and some methods 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 find the first number greater than 10 in the array.

Javascript
const numbers = [4, 9, 15, 7];
const result = numbers.[1](num => num > 10);
Drag options to blanks, or click blank then click option'
Afilter
Bfind
Cmap
Dreduce
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using filter returns an array, not a single element.
Using map transforms all elements, not find one.
2fill in blank
medium

Complete the code to check if some numbers in the array are even.

Javascript
const numbers = [1, 3, 5, 6];
const hasEven = numbers.[1](num => num % 2 === 0);
Drag options to blanks, or click blank then click option'
Aevery
Bfind
Cfilter
Dsome
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using every checks all elements, not some.
Using find returns the element, not a boolean.
3fill in blank
hard

Fix the error in the code to find the first string longer than 3 characters.

Javascript
const words = ['cat', 'dog', 'bird'];
const longWord = words.[1](word => word.length > 3);
Drag options to blanks, or click blank then click option'
Afind
Bsome
Cfilter
Dmap
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using some returns a boolean, not the element.
Using filter returns an array of all matches.
4fill in blank
hard

Fill both blanks to create an array of words longer than 4 characters using filter and check if some words start with 'a'.

Javascript
const words = ['apple', 'bat', 'anchor', 'cat'];
const longWords = words.[1](word => word.length > 4);
const hasAStart = words.[2](word => word.startsWith('a'));
Drag options to blanks, or click blank then click option'
Afilter
Bfind
Csome
Dmap
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using find instead of filter returns only one word.
Using map does not filter or check conditions.
5fill in blank
hard

Fill all three blanks to find the first number divisible by 3, check if some numbers are negative, and filter numbers greater than 5.

Javascript
const nums = [2, -3, 6, 8];
const firstDiv3 = nums.[1](num => num % 3 === 0);
const hasNegative = nums.[2](num => num < 0);
const greaterThan5 = nums.[3](num => num > 5);
Drag options to blanks, or click blank then click option'
Afilter
Bsome
Cfind
Devery
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using every instead of some for checking negatives.
Using map instead of filter for filtering numbers.