Untitled

 avatar
unknown
plain_text
a year ago
426 B
5
Indexable
function compareNumbers(arr) {

    let comparisonResult = "";
    if (arr[0] > arr[1]) {
        comparisonResult = "greater";
    } else if (arr[0] < arr[1]) {
        comparisonResult = "smaller";
    } else {
        comparisonResult = "equal";
    }

    if (comparisonResult === "equal") {
        return "Both numbers are equal.";
    }

    return `${arr[0]} is ${comparisonResult} than ${arr[1]}`;
}
Editor is loading...
Leave a Comment