(function main() {
let sum = 0;
for (let i = 0; i < 5; i++) {
/** @type {string} */
console.log('숫자 입력해라 ㅇㅅㅇ');
const input = readlineSync(); // readlineSync() 어떻게 하지
const n =
input !== '' && input.replace(/[0-9]+/, '').length !== 0
? Number(input)
: 0;
sum += n;
}
console.log('합', sum);
})();
심심해서 동기적으로 입력 5개 받고 합 구하는 함수 구해보려는 데
외부 모듈 다운 안 받고 내부 모듈만으로 readlineSync 어캐해야 하지 ㅇㅅㅇ?
async function main() const input = await readlineSync()
const it = rl[Symbol.asyncIterator](); const input = await it.next(); const value = line1.value; 이렇게도 되더라 ㅇㅅㅇ
async await 쓰는 건 알겠는 데 readlineSync라는 함수 자체는 없음 ㅇㅅㅇ
그냥 대충 저런 형태로 구현해보라는 의미엿음