Answers for "if string upper"

1

check if whole string is uppercase

#include <iostream>
#include <string>
#include <algorithm>

int main() {
    std::string s = "HELLo";
    if (std::all_of(s.begin(), s.end(), [](unsigned char c){ return std::isupper(c); })) {
        std::cout << "Is uppercase." << '\n';
    } else {
        std::cout << "Is not uppercase." << '\n';
    }
}
Posted by: Guest on December-26-2021
0

check to see if work is uppercase javascript

var word = 'apple' //Expected: false

//Use word[0] to grap the first letter
if (word[0] == word[0].toUpperCase()) {
  //Word is uppercase
} else {
  //Word is not uppercase
}
Posted by: Guest on July-15-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language