Tuesday, 9 June 2020

Use of sort() & reverse() Function

<script type="text/javascript">
function f1() {
    var Products = ['A','C','D','B'];
    Products.sort();
    Products.reverse();
    document.write(`${Products.toString()}`);
}
f1();
</script>

Using 'sort()'                    output:- A B C D
Using both 'sort()' & 'reverse()' output:- D C B A



Posted By: pankaj_bhakre

No comments:

Post a Comment