Hi, new to competitive programming, the only language I know is Javascript, but if I choose the javascript option, I would not even understand how to get input and how to print output on both sites, for some problems is Hackerrank, which looks like this
function processData(input) {
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});
And in the same hackerrank for some problems, the source code looks like this:
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
process.stdin.on('end', function () {
input_stdin_array = input_stdin.split("\n");
main();
});
function readLine() {
return input_stdin_array[input_currentline++];
}
function main() {
var n = parseInt(readLine());
}
While in hackerearth the source code is as follows
function main(input) {
process.stdout.write("Hello World!");
}
process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";
process.stdin.on("data", function (input) {
stdin_input += input;
});
process.stdin.on("end", function () {
main(stdin_input);
});
If someone gives me an example of a program on how to get the input and print the output on these sites or any permitted program of these sites using javascript, I also think.
source
share