A Syntax Highlighter - Prism.js is used to show the code from the HTML page.
function sumOfAllFears() {
document.getElementById("button").addEventListener('click', () => {
let userInput1 = parseInt(document.getElementById("userInput1").value);
let userInput2 = parseInt(document.getElementById("userInput2").value);
let userInput3 = parseInt(document.getElementById("userInput3").value);
let userInput4 = parseInt(document.getElementById("userInput4").value);
let userArray = [userInput1, userInput2, userInput3, userInput4];
let k = parseInt(document.getElementById("k").value);
let sumNumbers = sumNumbersFunction(userArray, k);
let sumNumberOne = sumNumbers[0];
let sumNumberTwo = sumNumbers[1];
document.getElementById('printBox').innerHTML = `${sumNumberOne} + ${sumNumberTwo} = ${k}`;
})
function sumNumbersFunction(userArray, k) {
var sumNumbers = [];
for (let i = 0; i < userArray.length; i++) {
let map1 = userArray.map(x => x + userArray[i]);
let map1includes = map1.includes(k, 0);
if (map1includes == true) {
sumNumbers.push(userArray[i])
}
if (sumNumbers.length != 2) {
document.getElementById('printBox').innerHTML = ``;
} else {
return sumNumbers;
}
}
}