I am currently developing a web application that performs addition operations on integers. Within this application, I have implemented two functions named num1() and num2() to retrieve the integers provided by the user for calculation. My objective is to modify the color of the output text based on whether the sum of the integers is negative. How can I achieve this using JavaScript exclusively?
While I have come across numerous jQuery solutions, my preference is to accomplish this task solely with JavaScript.
function addIntegers() {
var sum = num1() + num2();
if(sum < 0) {
document.getElementById('display').innerHTML = "Result: " + sum;
} else {
document.getElementById('display').innerHTML = "Result: " + sum;
}
}