|
charAt, charCodeAt, fromCharCode |
by webproger on 2020-02-09 |
<!DOCTYPE html><html><head>
</head><body>
<script>
var c = 3;
var s = "대한민국";
for(i=0; i<s.length; i++) {
document.write(s.charCodeAt(i));
document.write(' ');
document.write(s.charAt(i));
document.write('<br>');
}
var o = '';
for(i=0; i<s.length; i++) {
var n = s.charCodeAt(i);
o += String.fromCharCode(n+c);
}
for(i=0; i<o.length; i++) {
document.write(o.charCodeAt(i));
document.write(' ');
document.write(o.charAt(i));
document.write('<br>');
}
s = '';
for(i=0; i<o.length; i++) {
var n = o.charCodeAt(i);
s += String.fromCharCode(n-c);
}
for(i=0; i<s.length; i++) {
document.write(s.charCodeAt(i));
document.write(' ');
document.write(s.charAt(i));
document.write('<br>');
}
</script>
</body></html>
45824 대
54620 한
48124 민
44397 국
45827 댃
54623 핟
48127 믿
44400 군
45824 대
54620 한
48124 민
44397 국 |