Javascript String toJadenCase()
String.prototype.toJadenCase = function () { return this.replace(/(^|\s)(\w)/g, function(match, grup1, grup2) { return grup1+(grup2).toUpperCase(); });//from w ww.j a va 2s . co m }; console.log('caio cesar de lima furlan'.toJadenCase());
String.prototype.toJadenCase = function () { return this.replace(/(^|\s)(\w)/g, function(match, group1, group2) { console.log(group1, group2);/* w w w. j av a 2s. co m*/ return group1+(group2).toUpperCase(); }); };
String.prototype.toJadenCase = function() { return this.split(" ").map((word) => { return word[0].toUpperCase() + word.slice(1); }).join(" "); };
String.prototype.toJadenCase = function () { return this.split(" ").map(function(word){ return word.charAt(0).toUpperCase() + word.slice(1) }).join(" ")/*from ww w .j a va 2s . co m*/ };
// http://www.codewars.com/kata/jaden-casing-strings String.prototype.toJadenCase = function () { return this.split(' ').map(w => w.slice(0,1).toUpperCase() + w.slice(1)).join(' '); };
String.prototype.toJadenCase = function () { return this.split(" ").map( function(str) { return str.charAt(0).toUpperCase() + str.slice(1); } ).join(" ");/*from w w w .j a va2 s . com*/ };
String.prototype.toJadenCase = function () { return this.replace(/(?:^|\s)\S/g, word => word.toUpperCase()); };
String.prototype.toJadenCase = function () { return this//from w w w .j av a2 s. com .split(' ') .map(word => capitalize(word)) .join(' ') }; function capitalize(word) { return word[0].toUpperCase()+ word.slice(1) }
String.prototype.toJadenCase = function(){ return this.split(' ').map(function(word){ return word.charAt(0).toUpperCase() + word.slice(1); }).join(' ');/*w w w .j a v a 2 s .com*/ } console.log("joko purwanto".toJadenCase());
String.prototype.toJadenCase = function () { return this.split(' ').map((element)=>{ return element[0].toUpperCase() + element.substr(1); }).join(' ');//from w w w .j a va 2 s . c om };
//Jaden Casing Strings String.prototype.toJadenCase = function () { var sentence = this.split(' ').map(function(word) { return word.charAt(0).toUpperCase().concat(word.slice(1)); });/*from w w w . jav a 2 s .c o m*/ return sentence.join(' '); };
String.prototype.toJadenCase = function () { return this.replace(/(^|\s)(\w)/g, function(match, group1, group2) { return group1+(group2).toUpperCase(); });/* w w w . ja v a2s .c om*/ }; console.log('fabio fabio'.toJadenCase());
String.prototype.toJadenCase = function () { let returnValue = [] this.split(' ').map(function(item){ returnValue.push(item[0].toUpperCase() + item.slice(1)) })//from w w w . ja va 2s. c o m return returnValue.join(' ') }; persistence = function(num){ let counter = 0 let numArray = num.split() ) }
String.prototype.toJadenCase = function () { var words = this.split(" "); var newWord = true; var res = ""; for (var i = 0; i < this.length; i++) { if (newWord) { res += this[i].toUpperCase();/*w w w . ja v a 2 s . c o m*/ newWord = false; } else { res += this[i]; } if (this[i] == " ") { newWord = true; } } return res; };
String.prototype.toJadenCase = function () { var arr = this.split(" "); var transformedArr = []; arr.map(function(current){ var something = current.charAt(0).toUpperCase() + current.slice(1); transformedArr.push(something)/* w w w . j a v a 2 s . c o m*/ }) var final = transformedArr.join(" ") console.log(final); };
String.prototype.toJadenCase = function () { var jadenArray = this.split(''); jadenArray[0] = jadenArray[0].toUpperCase(); for (var a = 0; a <= jadenArray.length; a++) { if (jadenArray[a] === ' ') { jadenArray[a+1] = jadenArray[a+1].toUpperCase(); } }/*from ww w . j a v a 2 s . c om*/ return jadenArray.join(''); };
String.prototype.toJadenCase = function () { return this.split(' ').map(el => el[0].toUpperCase()+el.slice(1)).join(' '); }; var str = "How can mirrors be real if our eyes aren't real"; console.log(str.toJadenCase());/*from w ww . java2 s .c om*/ //return this.replace(/(^|\s)[a-z]/g, function(x){ return x.toUpperCase(); });
module.exports = "side effect"; String.prototype.toJadenCase = function () { let strArray = this.split(' '); let jadenArray = strArray.map((str)=>{ let firstLetter = str.substr(0, 1); let rest = str.substr(1); firstLetter = firstLetter.toUpperCase(); return firstLetter + rest; });// w w w. ja v a2 s . c om let result = jadenArray.join(' '); return result; };
module.exports = "side effect"; String.prototype.toJadenCase = function () { let strArray = this.split(' '); let jadenArray = strArray.map((str)=>{ let firstLetter = str.substr(0, 1); let rest = str.substr(1); firstLetter = firstLetter.toUpperCase(); return firstLetter + rest; });/*from ww w.j av a2 s.c om*/ let result = jadenArray.join(' '); return result;;; };
String.prototype.toJadenCase = function () { return this.split(' ').map(([first, ...text]) => first.toUpperCase()+text.join('')).join(' ') }; var str = "How can mirrors be real if our eyes aren't real"; console.log(str.toJadenCase())/*from w w w . ja v a 2s . co m*/ //"How Can Mirrors Be Real If Our Eyes Aren't Real"
String.prototype.toJadenCase = function () { let holder = ""; let array = this.split(" ") for (var i = 0; i < array.length; i++) { holder += array[i].charAt(0).toUpperCase() + array[i].slice(1) + " " } return holder.trim(); };
String.prototype.toJadenCase = function () { return this.replace(/(^|\s)(\w)/g, function(match, group1, group2) { console.log(group1, group2);//from w w w. j a v a2s . c om return group1+(group2).toUpperCase(); }); }; console.log('miguel miguel miguel'.toJadenCase());
// note this solution uses ES6 String.prototype.toJadenCase = function () { var result = Object.values(this).join(""); for (var i = 0; i < result.length; i++){ if (result[i] === " "){ result = result.substr(0, i) + " " + result[i+1].toUpperCase() + result.substr(i+2); }// www. j a v a2s. c om } return result; };
String.prototype.toJadenCase = function () { var result = this.charAt(0).toUpperCase() + this.slice(1); for (var i = 0; i < result.length; i++){ if (result[i] === " "){ result = result.substr(0, i) + " " + result[i+1].toUpperCase() + result.substr(i+2); }/* w w w. j av a 2s. c om*/ } return result; };
String.prototype.toJadenCase = function () { const str = this.split(' ').map( x => { return x.split('') }).map( x => { x[0] = x[0].toUpperCase(); return x }); return str.map( x => { return x.join('') }).join(' '); }; // - Test Cases - let str = "How can mirrors be real if our eyes aren't real"; str.toJadenCase()//, "How Can Mirrors Be Real If Our Eyes Aren't Real");
// url: https://www.codewars.com/kata/5390bac347d09b7da40006f6/train/javascript String.prototype.toJadenCase = function () { let str = this instanceof String ? this.toString() : ''; return str.split(/\s+/) .map(s => s.charAt(0).toUpperCase() + s.slice(1)) .join(' ') };
/* eslint-disable no-console */ /* eslint-disable no-unused-vars */ // Capitalize every word of the input string String.prototype.toJadenCase = function () { var newString = ''; this.split(' ').forEach(function(word) { var newWord = word[0].toUpperCase() + word.slice(1); newString = newString + newWord + ' '; });//w ww . ja va 2 s .c o m return newString.trim(); };
String.prototype.toJadenCase = function () { //.../*from ww w . ja v a2 s . co m*/ var arrayOfStrings = this.split(" ").map(function(element) { var upperCase = element.charAt(0).toUpperCase(); var rest = element.slice(1,element.length); console.log(upperCase + rest); return upperCase + rest; } ).join(" "); return arrayOfStrings; };
// Your task is to convert strings to how they would be written by Jaden Smith. // The strings are actual quotes from Jaden Smith, but they are not capitalized in the same way he originally typed them. // Example://from w w w. j a v a 2 s . c o m // Not Jaden-Cased: "How can mirrors be real if our eyes aren't real" // Jaden-Cased: "How Can Mirrors Be Real If Our Eyes Aren't Real" String.prototype.toJadenCase = function() { return this.replace( /(^|\s)([a-z])/g, function(m, p1, p2){return p1+p2.toUpperCase();}); };
//Jaden Casin Strings (7 kyu) String.prototype.toJadenCase = function () { var words = this.split(' '); //taking string and making array of words var jadenCase = []; for (var i = 0; i < words.length; i++) { jadenCase.push(words[i][0].toUpperCase() + words[i].substring(1)); //take empty array and add newly capitalized words as individual array items }//ww w . ja v a2 s . c om return jadenCase.join(' '); // make the array back into a string };
String.prototype.toJadenCase = function () { words = this.split(" "); for(i = 0; i < words.length; i++) { words[i] = words[i].substr(0,1).toUpperCase() + words[i].substr(1).toLowerCase(); }/* w ww. j a va2 s . c om*/ return words.join(" "); }; debug(("How can mirrors be real if our eyes aren't real").toJadenCase()); // How Can Mirrors Be Real If Our Eyes Aren't Real debug(("Testing this out").toJadenCase()); // Testing This Out
//capitalize the first letter of every word in a string string.prototype.toJadenCase = function(){ return this.spilt(" ").map(function (word){ return word.charAt(0).toUpperCase()+ word.slice(1); }).join(" ");/*from w w w . j ava2 s. c om*/ } //str.split(" ") splits a string into an array of substrings // var str = "How are you doing today?"; //var res = str.split(" "); // result will be : how, are, you, doing, today? // how do i call this function haaalp
var str = "How can mirrors be real if our eyes aren't real"; String.prototype.toJadenCase = function () { //.../*from w ww . j a v a2 s . co m*/ var capIt = this.split(" "); var array = []; console.log(capIt); for (var i = 0; i < capIt.length; i++){ var string = capIt[i].charAt(0).toUpperCase() + capIt[i].substring(1); array.push(string); } console.log(array.join(' ')); }; str.toJadenCase();
// String.prototype.toJadenCase = function () { // //.../* w w w . j a v a2s . com*/ // var capitalize = false; // var result = ""; // for(var i = 0; i < this.length; i++){ // if(i === 0 || this[i - 1] === " " ){ // result += this[i].toUpperCase(); // } else{ // result += this[i]; // } // } // return result; // }; String.prototype.toJadenCase = function() { return this.split(" ").map(function(element){ return element.charAt(0).toUpperCase() + element.slice(1); }).join(" "); };
String.prototype.toJadenCase = function () { var arr = this.split(' '); var ret = ""; for (var i = 0, len = arr.length; i < len; i++) { ret += arr[i].charAt(0).toUpperCase() + arr[i].substr(1).toLowerCase() + " "; }/*from ww w . j a v a 2s . com*/ ret = ret.substring(0,ret.length - 1); return ret; }; var str = "How can mirrors be real if our eyes aren't real"; var ret = str.toJadenCase(); //Test.assertEquals(str.toJadenCase(), "How Can Mirrors Be Real If Our Eyes Aren't Real");
//Practicing with codewars' exercises in javascript String.prototype.toJadenCase = function () { var strLowerCase = this.toLowerCase(); var wordArray = strLowerCase.split(' '); var newestArray = wordArray.map(function (val) { var temporaryArray = val.split(''); var sliceArray = temporaryArray.slice(1, temporaryArray.length); var togetherArray = sliceArray.join(''); var upperCaseWord = temporaryArray[0].toUpperCase() + togetherArray; return upperCaseWord; });/*from ww w.jav a 2s.co m*/ var capitalizedString = newestArray.join(" "); return capitalizedString; };
String.prototype.toJadenCase = function () { //.../*w ww.j ava 2 s . c om*/ var upCase = ''; upCase += this.toString().replace(/\S\w*/g, function(a){ return a[0].toUpperCase() + a.slice(1, a.length); }) return upCase; }; console.log("How can mirrors be real if our eyes aren't real".toJadenCase());
String.prototype.toJadenCase = function(){ return this.replace(/(^|\s|[^A-Za-z0-9_'])[a-z]/g, function(x){ return x.toUpperCase(); }); } function jadenCasingString(){ var i ,j;// w w w . j a va 2s . c o m var nStr = ""; for (i = 0;i < arguments.length;i++){ if(typeof arguments[i] == "string"){ nStr += arguments[i].toJadenCase(); } else{ for (j = 0;j < arguments[i].length;j++){ nStr += jadenCasingString(arguments[i][j]); } } } return nStr; } var cite = "How can mirrors be real if our 1eyes aren't real, ,others ak47"; console.log(jadenCasingString(cite, [' knight', '991event', ['King\'s hand', '1world one Dr3am']]));
String.prototype.toJadenCase = function () { //...//from w w w .j a va 2 s . c o m //var str = "How can mirrors be real if our eyes aren't real"; var newStr = this.split(' '); var jadenStr = ''; for(var i = 0; i < newStr.length; i++){ for(var j = 0; j < newStr[i].length;j++){ if(j == 0){ jadenStr += newStr[i][j].toUpperCase(); } else { jadenStr += newStr[i][j]; } //console.log(newStr[i].length) } if(i < newStr.length - 1){ jadenStr += " "; } } return jadenStr; };
String.prototype.toJadenCase = function () { // split each word into an array var wordArr = this.split(" "); // var to build return string var jadenWordStr = ""; // loop through wordArr wordArr.forEach (function (word, index, arr) { // get first char and uppercase it var upperFirst = word.charAt(0).toUpperCase(); // if not last word add word and space to return string if (index < wordArr.length - 1) { jadenWordStr += upperFirst.concat(word.substr(1)) + " "; } else {/* ww w.j a v a2s . c o m*/ jadenWordStr += upperFirst.concat(word.substr(1)); } }); // return in JadenCase return jadenWordStr; };
/*Description:/*from w ww . j a va 2s . co m*/ Description: Jaden Smith, the son of Will Smith, is the star of films such as The Karate Kid (2010) and After Earth (2013). Jaden is also known for some of his philosophy that he delivers via Twitter. When writing on Twitter, he is known for almost always capitalizing every word. Your task is to convert strings to how they would be written by Jaden Smith. The strings are actual quotes from Jaden Smith, but they are not capitalized in the same way he originally typed them. Example: Not Jaden-Cased: "How can mirrors be real if our eyes aren't real" Jaden-Cased: "How Can Mirrors Be Real If Our Eyes Aren't Real" Note that the Java version expects a return value of null for an empty string or null. */ String.prototype.toJadenCase = function () { var words = this.valueOf().split(' '); for ( var i = 0, len = words.length; i < len; i++ ) { words[ i ] = words[ i ].charAt(0).toUpperCase() + words[ i ].substr( 1 ); } return words.join(' ').trim(); };