How to take input in javascript in codechef

how to take input in any problem in js in codechef

it is an easy task follow the syntax written below
let a = prompt(‘enter srtring’) // remember it always take string as input so
a = Number.ParseInt(a) // to convert possible string to number like ‘4’

1 Like

Got this error:

/mnt/sol.js:2
let word = prompt("enter srtring");
           ^

ReferenceError: prompt is not defined
    at Object.<anonymous> (/mnt/sol.js:2:12)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.16.1

To learn how to take input in JavaScript on CodeChef, checkout this module - Taking user input Practice Problem in JavaScript - CodeChef

This will teach you basics of taking input. But because most problems require taking multiple test cases as input, you can learn that from here - What are test cases Practice Problem in JavaScript - CodeChef