+ 2
Function Parameters
//I’m new to JS, so please bear with me. Sometimes it’s very useful to set reminder to help you accomplish all of your tasks. The program you are given takes an event as input. Complete the function-reminder to take that event as argument and output the corresponding message. Sample Input workout Sample Output You set a reminder about workout https://code.sololearn.com/cuiD0EgI5o5W/?ref=app
21 Antworten
+ 7
It's not necessary to call main() in Js practices since it's done by the compiler itself.
//main()
+ 3
It's a pro-content. And coaches are private once. Others can't see your code. Share your code link by saving it in playground and needed details of problem...
Hope you understand..
+ 2
Jayakrishna🇮🇳 That code gave the following:
./Playground/file0.js:4
var eventExample = readLine();
^
ReferenceError: readLine is not defined
at main (./Playground/file0.js:4:24)
at Object.<anonymous> (./Playground/file0.js:12:1)
at Module._compile (internal../Playground/:1063:30)
at Object.Module._extensions..js (internal../Playground/:1092:10)
at Module.load (internal../Playground/:928:32)
at Function.Module._load (internal../Playground/:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
+ 2
//Tahiti🍷 if it is JS project of function parameters, then this code worked for me. I tested it now.
function main() {
var eventExample = readLine();
// function call
setReminder(eventExample)
}
//complete the function
function setReminder(eventExample) {
console.log("You set a reminder about "+ eventExample);
}
+ 1
Jayakrishna🇮🇳 It took me some time to get everything added. The system does not allow me to paste all information at the top in the question field. I had to enter the instructions and my code as replies. Others had already begun posting replies before I was finished adding information.
+ 1
//try this:
function main() {
var eventExample = readLine();
// function call
setReminder(eventExample)
}
//complete the function
function setReminder(eventExample) {
console.log("You set a reminder about " + eventExample);
};
main();
+ 1
Jayakrishna🇮🇳 I used your code:
function main(){
const rl = require('readline');
const rls = rl.createInterface({
input: process.stdin,
output: process.stdout } );
rls.on('line', (input) => { console.log(`You can add reminder to ${input}`); });
}
main();
/*And the output was:
You can add reminder to
*/
/*But I don’t understand the code, because the tutorial didn’t teach any of this above. I don’t understand the meaning of readLine and how it fits in. I think I need to get further through the tutorial to understand better. Thank you.*/
+ 1
This is one way of taking input in node.js manually ..
Importing readline into program to use it.
rl is a readline instance of added library
Next line creates an interface for input dialogue box
Next line process input on input text ..
Iam not much know about it more, about node.js. I found it on net source.
Just gave for temporary unlock a lesson.. Hoping may helps..
But it should work without those as it before. But what is the way sololearn supporting input now idk..
edit:
https://nodejs.org/docs/latest-v15.x/api/readline.html
Tahiti🍷 You're welcome...
+ 1
Jayakrishna🇮🇳 to your question about my code for Logical or Boolean Operators, here is the code that worked for me:
function main() {
var hour = parseInt(readLine(), 10);
// Your code goes here
var meridiem = (hour <=12) ? "am": "pm";
console.log(meridiem);
}
+ 1
Jayakrishna🇮🇳 Thanks again. I tried your code above. My code bit is here:
https://code.sololearn.com/cL4tK8gut4wc/?ref=app
It still throws an error. 😵💫
+ 1
Jayakrishna🇮🇳 There is no error. The console says “No output” when I run the code.
+ 1
Jayakrishna🇮🇳 Thank you for not giving up! You are awesome! The problem was that I was copying and pasting your helpful code into the playground. For some reason, it says “No output” as a result. But after you reported that you tested it and it worked, I decided to paste it into the Code Coach exercise, and it worked there! 😵💫😁
Thank you, my friend! 🏆
+ 1
😇 you're welcome.. Tahiti🍷 👍
0
Defaultly it should work.. Otherwise it need to import third party libraries..
edit:
Tahiti🍷 in this , is your code worked fine before?
https://www.sololearn.com/Discuss/2896745/?ref=app
edit:
function main(){
const rl = require('readline');
const rls = rl.createInterface({
input: process.stdin,
output: process.stdout } );
rls.on('line', (input) => { console.log(`You set a reminder about ${input}`); });
}
main();
0
//Yes. In same way this should work.
But may sololearn changed settings or code playground not working this way.. I don't know.
function main() {
var eventExample = readLine();
// function call
setReminder(eventExample)
}
//complete the function
function setReminder(eventExample) {
console.log("You set a reminder about " + eventExample);
};
main();
Forget tempararly, go with next.
edit:
//the output text in last post, I edited to
console.log(`You set a reminder about ${input}`) ;
0
Simba Thank you. When I remove the “main()”, the console says No output.
Likewise, the console says No output for the following code:
function main() {
var eventExample = readLine();
// function call
setReminder(eventExample)
}
//complete the function
function setReminder(eventExample) {
console.log("Remember to " + eventExample)
};
//I don’t understand how it should be coded to give a correct output.
0
What is the error there ? is it same or different?
0
Can you help me please 🥺?
0
//I hope this will be helpful for u
function main() {
var eventExample = readLine();
// function call
setReminder(eventExample)
}
//complete the function
function setReminder(event) {
console.log('You set a reminder about '+ event);
};
- 1
Bonsoir je suis nouveau ici