0
0
Node.jsframework~30 mins

Why debugging skills matter in Node.js - See It in Action

Choose your learning style9 modes available
Why debugging skills matter
📖 Scenario: You are building a simple Node.js script that processes a list of numbers to find which are even. Debugging skills help you find and fix mistakes in your code so it works correctly.
🎯 Goal: Create a Node.js script that holds a list of numbers, sets a threshold number, filters the list to keep only even numbers greater than the threshold, and finally exports the filtered list.
📋 What You'll Learn
Create an array called numbers with the values [2, 5, 8, 11, 14]
Create a variable called threshold and set it to 6
Use Array.filter() with a callback that keeps numbers greater than threshold and even
Export the filtered array as filteredNumbers
💡 Why This Matters
🌍 Real World
Filtering data based on conditions is common in real-world apps, like showing only available products or valid user inputs.
💼 Career
Debugging and filtering data are essential skills for Node.js developers working on backend services and APIs.
Progress0 / 4 steps
1
DATA SETUP: Create the numbers array
Create an array called numbers with these exact values: [2, 5, 8, 11, 14]
Node.js
Need a hint?

Use const numbers = [2, 5, 8, 11, 14]; to create the array.

2
CONFIGURATION: Set the threshold value
Create a variable called threshold and set it to the number 6
Node.js
Need a hint?

Use const threshold = 6; to set the threshold.

3
CORE LOGIC: Filter numbers greater than threshold and even
Create a variable called filteredNumbers that uses numbers.filter() with a callback function. The callback should keep numbers greater than threshold and that are even (divisible by 2).
Node.js
Need a hint?

Use numbers.filter(number => number > threshold && number % 2 === 0) to filter the array.

4
COMPLETION: Export the filtered numbers array
Add a line to export filteredNumbers using module.exports.
Node.js
Need a hint?

Use module.exports = { filteredNumbers }; to export the variable.