I’m trying to change the background color on strings that contain certain text styles (using javascript). For example, I want to make all the text that doesn’t contain any caps have a green background and any string that contains a word that’s all caps have a red background.
I know I’d need to use a conditional if statement but I’m not sure how I can achieve what is desired.
Below is a link to my js fiddle. Any thoughts would be appreciated. Thanks!
-D
Basically, you split your string by words, loop through those words, then in each word loop through each letter and check if it is uppercase by checking if the letter and the letter.toLowerCase() are different. Something like this: