Assignment:
* Write a function, called by a button, that will accept a string and capitalize
any word sent to it in any case, mixed or otherwise.
* Write a function, called by a button, that will accept a string
(mixed or otherwise) and make the first letter a capital and
the remaining letters lowercase. HINT
* Write a function, called by a button, that will tell me
where the first occurrance of the letter Z is in the string Kazul is my cat.
function capitalizeIt(word) {
wordToCapitalize = prompt("Write a word you want capitalized.", "");
allCaps = wordToCapitalize.toUpperCase();
alert("Your word capitalized is " +allCaps);
}
function capFirstLetter() {
wordToCapitalize = prompt("Write a word", "");
letterSelected = wordToCapitalize.substring(0,1);
// alert(letterSelected);
firstCap = letterSelected.toUpperCase();
// alert(firstCap);
otherLetters = wordToCapitalize.substring(1);
// alert(otherLetters);
smallLetters = otherLetters.toLowerCase();
wordCapitalized = firstCap + smallLetters;
//alert(wordCapitalized);
alert("Your word with only the first letter capitalized is " + wordCapitalized);
}
/* QUESTION - when I put a comma after string above, the wordCapitalized does not print. Why?
Like this: alert("Your word with the first letter capitalized is ", + wordCapitalized); */
function findTheZ() {
var catOfSandi = "Kazul";
var where_is_z = catOfSandi.indexOf("z");
alert("The z is at position " + where_is_z + ".");
}