Sunday, March 19, 2023

Coding Challenge #26

 // from https://www.codecademy.com/resources/blog/20-code-challenges/
// reverse the order of words in a sentence without paying attention to punctuation.
// as there was a higher level counterpart to this, this version was supposed to be extremely quick and bare-bones
function reverse(str){
    var words = str.split(" ");
    var o = "";
    for(var xint = words.length - 1;xint > -1;xint--){
        o += words[xint] + " ";
    }
    return o;
}

No comments:

Post a Comment

Coding Challenge #54 C++ int to std::string (no stringstream or to_string())

Gets a string from an integer (ejemplo gratis: 123 -> "123") Wanted to come up with my own function for this like 10 years ago ...