JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" value="imalatçı" class="text">
<input class="button" type="button" value="getir" />
<div></div>
CSS
div {
margin-top: 30px;
}
JavaScript
String.prototype.replaceAt = function (index, character) {
return this.substr(0, index) + character + this.substr(index + character.length);
}
var arr;
$("input.button").click(function () {
arr = [$("input.text").val()];
words(arr[0], 0);
$("div").html("");
for (var w in arr) {
$("div").append(arr[w] + "<br>");
}
});
function words(word, index) {
var chars = ["ı", "o", "u", "g", "s", "c", "i", "ö", "ü", "ğ", "ş", "ç"];
for (var i = index; i < word.length; i++) {
for (var j = 0; j < chars.length; j++) {
if (word[i] == chars[j]) {
var temp = word;
temp = temp.replaceAt(i, chars[(j + 6) % chars.length]);
arr.push(temp);
words(temp, i + 1);
}
}
}
}