文字コードから文字を作る String.fromCharCode
ひとことで言うと
指定された文字コードから、その文字コードに相当する文字1文字だけを含む文字列を作ります。
ブロックとコード
文字コード0の文字
ブロックの文言は公式の日本語版に合わせています(形は簡易表示です)。
String.fromCharCode(0)String.from_char_code(0)引数(ひきすう)
引数とは、ブロックの中で自分で選んだり入力したりする部分のことです。
| 名前 | 選べる値 | 意味 |
|---|---|---|
| code | 数値 |
使用例
So, you can make the letter B from:
JavaScript
let letItBe = String.fromCharCode(66);Python
letItBe = String.from_char_code(66)Decode a secret message from an array of numbers!
JavaScript
let secret = [67, 111, 111, 107, 105, 101, 115, 33];
let decoded = "";
for (let code of secret) {
decoded = decoded + String.fromCharCode(code);
}Python
secret = [67, 111, 111, 107, 105, 101, 115, 33]
decoded = ""
for code in secret:
decoded = decoded + String.from_char_code(code)