結果

問題 No.163 cAPSlOCK
ユーザー megane_anko
提出日時 2021-02-09 02:59:28
言語 JavaScript
(node v23.5.0)
結果
AC  
実行時間 68 ms / 5,000 ms
コード長 781 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 41,076 KB
最終ジャッジ日時 2024-07-06 07:03:07
合計ジャッジ時間 2,395 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

const input = require('fs').readFileSync('/dev/stdin', 'utf8');

//文字列を1文字ずつ分割して配列にする、改行の部分を削除
//const ary = input.match(/.{1}/g)
const arr = input.split('\n')[0];
//答えを入れる配列を生成
let arr2 = [];
//console.log(arr);


for (let i = 0; i < arr.length; i++) {
    if (arr[i].match(/^[A-Z]*$/)) {
        //小文字に変換した文字を返す、処理してるだけ。
        arr[i].toLowerCase();
        //ary[i]に代入して、新しく作った配列に追加
        arr2.push(arr[i].toLowerCase());
        //console.log('if 文に入りました');
    } else {
        //大文字に変換
        arr[i].toUpperCase();
        arr2.push(arr[i].toUpperCase());
    }
}


console.log(arr2.join(""));
0