Advertisement
Valleri

BAd solution

Jul 21st, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fixCasing(value) {
  2.  
  3.     function randomCase (word) {
  4.         var result = "";
  5.         for (var i = 0; i < word.length; i++) {
  6.             var randol = Math.random();
  7.             if (randol <= 0.5) {
  8.                 result += word.charAt(i).toUpperCase();
  9.             }
  10.             else {
  11.                 result += word.charAt(i).toLowerCase();
  12.             }
  13.         }
  14.         return result;
  15.     }
  16.     var result = value.match(/<mixcase>(.*?)<\/mixcase>/g).map(function (val) {
  17.         return val.replace(/<\/*.*?>/g, '');
  18.     });
  19.     var applyMixed = value;
  20.     value = '\"' + value + '\"';
  21.     console.log(value);
  22.     for (var i = 0; i < result.length; i++) {
  23.         value += ".replace('/<mixcase>(.*?)<\/mixcase>\/g, result[" + i + '])';
  24.     }
  25.  
  26.     var newString = eval(value);
  27.  
  28.     console.log(newString);
  29.  
  30.  
  31.  
  32.     //var cleanText = value.replace(/<\/?[^>]+(>|$)/g, "");
  33.     // console.log(cleanText);
  34.  
  35.    
  36.  
  37.  
  38. }
  39.  
  40. fixCasing('We are <mixcase>living</mixcase> in a <upcase>yellow submarine</upcase>. We <mixcase>dont</mixcase> have <lowcase>anything<\/lowcase> else.');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement