This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function slasher(arr, howMany) { | |
if (howMany < 1) return arr; | |
else return arr.splice(howMany, arr.length); | |
} | |
slasher([1, 2, 3], 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function slasher(arr, howMany) { | |
if (howMany >= arr.length) return null; | |
else if (howMany === 0) return arr; | |
else arr.splice (0, howMany); return arr; | |
} | |
slasher([1, 2, 3], 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function slasher(array, howMany) { | |
return array.length <= howMany ? [] : howMany < 1 ? array : array.slice(howMany); | |
} | |
slasher([1, 2, 3], 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function largestOfFour(arr) { | |
/* | |
largestOfFour içeriğindeki değer sayısına göre; | |
*/ | |
// Kaç tane değerimiz var bakalım. Büyük sayıları buna atayacağız. | |
var cA = arr.length; | |
var fA = []; | |
for (var i = 0; i < cA; i++) { fA.push(0); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function titleCase(str){ | |
str = str.toLowerCase().split(' '); | |
/* | |
str = str.toLowerCase(); | |
str = str.split(' '); | |
*/ | |
for(var i = 0; i < str.length; i++){ | |
var cF = str[i].charAt(0); | |
str[i] = str[i].replace(cF, cF.toUpperCase()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverseString(str) { | |
str = str.split('').reverse().join(''); return str; | |
} | |
reverseString("hello", ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function factorialize(num) { | |
var deger = 1; | |
while(num > 1) deger *= num; num--; | |
return deger; | |
} | |
factorialize(5, ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findLongestWord(str) { | |
var cumle = str.split(' '); | |
var kacKelime = cumle.length; | |
var final = 0; | |
for(var i = 0; kacKelime > i; i++) if(final < cumle[i].length) final = cumle[i].length; | |
return final; | |
} | |
findLongestWord('The quick brown fox jumped over the lazy dog'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function end(str, target) { | |
var fL = target.length; | |
var result; | |
/* | |
Peki, sonraki noktayı dikkate almamak istersek? | |
str = str.replace(/\.\s*$/, ''); | |
*/ | |
str.substr(-fL) === target ? result = true : result = false; | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function repeat(str, num) { | |
var result = ''; | |
for(var i = 0; num > i; i++){ result += str; } | |
return result; | |
} | |
repeat("abc", 3, ""); |
OlderNewer