Skip to content

Instantly share code, notes, and snippets.

@eiszfuchs
Last active December 11, 2015 19:29
Show Gist options
  • Save eiszfuchs/4649179 to your computer and use it in GitHub Desktop.
Save eiszfuchs/4649179 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Namen</title>
<style>
body {
background: #8f1;
color: #fff;
}
#name {
font-family: sans-serif;
font-weight: 900;
font-size: 10em;
text-align: center;
}
</style>
</head>
<body>
<p id="name"></p>
<script>
Array.prototype.pick = function () {
"use strict";
var index = Math.floor(Math.random() * this.length);
return this[index];
};
String.prototype.capitalize = function () {
"use strict";
var i,
capitalized = "";
for (i = 0; i < this.length; i += 1) {
if (i === 0) {
capitalized += this[i].toUpperCase();
} else {
capitalized += this[i];
}
}
return capitalized;
};
var vokale = ("a_e_i_o_u_y").split("_");
var konsonanten = ("b_c_d_f_g_h_j_k_l_m_n_p_q_r_s_t_v_w_x_z_sch_ch_ph").split("_");
var generateName = function (muster) {
"use strict";
var i,
buchstabe,
name = "";
for (i = 0; i < muster.length; i += 1) {
if (muster[i] === "v") {
buchstabe = vokale.pick();
} else if (muster[i] === "k") {
buchstabe = konsonanten.pick();
}
name += buchstabe;
}
return name.capitalize();
};
document.getElementById("name").innerHTML = generateName("kvkvvk");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment