Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
426 B
2
Indexable
Never
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]}`;
}
Leave a Comment