From 8698ede2a20afefde766002726e247e8e8697d92 Mon Sep 17 00:00:00 2001 From: Kesse Date: Fri, 22 Dec 2017 12:55:00 +0000 Subject: [PATCH] Yet another alternative --- .../underscore_toCamelCase.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Problem-Set-2-Solutions/underscore_toCamelCase.js b/Problem-Set-2-Solutions/underscore_toCamelCase.js index f232da5..559887b 100644 --- a/Problem-Set-2-Solutions/underscore_toCamelCase.js +++ b/Problem-Set-2-Solutions/underscore_toCamelCase.js @@ -53,3 +53,22 @@ function underToCamel(underName) { // return camelCaseOutput; // } + + + + /* Solution 4 */ + +` +function underToCamel(str){ + var camel=''; + for(var i =0;i<=str.length-1;i++){ + if(str[i]!=="_"){ + camel+=str[i] + }else if(str[i]==="_"){ + camel+=str[i+1].toUpperCase(); + i++; + } + }return camel; +} + +`