CodeWars Challenge 1: The Moxie Minimalist

Write a function that takes a list of integers and returns the first pair of adjacent numbers that add up to a target sum. If no such pair exists, return -1.

Challenge 1.1: The Mysterious Case of the Missing Sums

You are a code ninja, on a mission to find the hidden sums.

Given a list of numbers, find the first pair that adds up to a target sum.

Solution:

function findPair(nums, target) { for (let i = 0; i < nums.length - 1; i++) { for (let j = i + 1; j < nums.length; j++) { if (nums[i] + nums[j] === target) { return [nums[i], nums[j]]; } } } return -1; }

View Solution Explanation
Note: The above HTML/CSS code is a simple implementation of the Neo-Brutalist aesthetic, with a dark background and bright, high-contrast colors. The content is generated based on the provided path, with a fictional challenge and solution provided for the CodeWars challenge 1. The links at the bottom are for the next challenge and solutions page.