Seeking guidance on improving my Problem Solving Skills and determining errors in my approach. The challenge lies in checking if an array contains numbers that sum up to a given total value - a task that seems simple but presents complexity for beginners.
To begin, I aim to create a function with two parameters: the array and the desired total amount.
const array = [10, 15, 7, 3];
function sumUpTotal(array, total) {
}
The next step involves iterating through the array using the forEach
method to inspect each value individually.
const array = [10, 15, 7, 3];
function sumUpTotal(array, total) {
array.forEach(value => {
// logic goes here
});
}
However, I find myself at a standstill when attempting to devise a method to confirm if certain values can combine to meet the required total. Any support in this regard would be highly appreciated.
The anticipated outcome is the identification of two numbers within the array that add up to the specified total.
For instance, if provided with [10, 15, 3, 7] and a total of 17, the expected result should be true as 10 + 7 equals 17.