使用例
Read an integer-cents checkout total
入力
function totalCents(items){return items.reduce(function(sum,item){return sum+item.cents*item.quantity;},0);}Expected answer
function totalCents(items) {
return items.reduce(function (sum, item) {
return sum + item.cents * item.quantity;
}, 0);
}- インデント文字列
- 引用符
Auto- 閉じ波括弧前のセミコロン
On- コメントを含める
On
Inspect Fahrenheit conversion and its zero-degree boundary
入力
function celsius(f){return(f-32)*5/9;}Expected answer
function celsius(f) {
return (f - 32) * 5 / 9;
}- インデント文字列
- 引用符
Auto- 閉じ波括弧前のセミコロン
On- コメントを含める
On
Switch an API message to double-quoted strings
入力
function message(name){return 'Hello, '+name+'!';}Expected answer
function message(name) {
return "Hello, " + name + "!";
}- インデント文字列
- 引用符
Double- 閉じ波括弧前のセミコロン
On- コメントを含める
On
Keep a note explaining a longitude-latitude pair
入力
// GeoJSON positions use longitude before latitude
var point={type:"Point",coordinates:[100,0]};Expected answer
// GeoJSON positions use longitude before latitude
var point = {
type: 'Point',
coordinates: [
100,
0
]
};- インデント文字列
- 引用符
Single- 閉じ波括弧前のセミコロン
On- コメントを含める
On
Remove a stale comment while keeping a leap-year check
入力
/* old debug note */function isLeap(y){return y%4===0&&(y%100!==0||y%400===0);}Expected answer
function isLeap(y) {
return y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0)
}- インデント文字列
- 引用符
Auto- 閉じ波括弧前のセミコロン
Off- コメントを含める
Off
パラメーター
| パラメーター | 既定値 | 入力と選択肢 |
|---|---|---|
| インデント文字列 | "\\t" | \n、\r、\t などのエスケープシーケンスに対応 |
| 引用符 | 自動 | 自動, シングル, 倍精度浮動小数点 |
| 閉じ波括弧前のセミコロン | true | オンまたはオフ |
| コメントを含める | true | オンまたはオフ |