,

JS Easy Solution for Calculating Number of Employees Who Met the Target in LeetCode 2798

Posted by

LeetCode 2798: Number of Employees Who Met the Target

LeetCode 2798: Number of Employees Who Met the Target

LeetCode 2798 is a programming problem that asks you to write a JavaScript solution to calculate the number of employees who have met or exceeded their target sales. This problem falls under the “easy” category and is a good exercise for beginners to practice their programming skills.

Problem Description

The problem states that you are given an array of integers representing the sales targets for each employee and another array of integers representing the actual sales made by each employee. Your task is to write a function that returns the number of employees who have met or exceeded their sales target.

JavaScript Solution

Here is a simple JavaScript solution to the LeetCode 2798 problem:

“`javascript
function employeesMetTarget(targets, sales) {
let count = 0;
for (let i = 0; i = targets[i]) {
count++;
}
}
return count;
}

// Example usage
const targets = [100, 200, 150, 300];
const sales = [110, 150, 160, 280];
console.log(employeesMetTarget(targets, sales)); // Output: 3
“`

Conclusion

The LeetCode 2798 problem is a good opportunity for beginner programmers to practice their JavaScript skills. By understanding the problem and implementing a solution like the one shown above, you can improve your problem-solving abilities and become more comfortable with writing code to solve programming challenges.

0 0 votes
Article Rating
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@karimbouche3563
6 months ago

Good evening bro as always waiting tour video ,great …