+ 2

What is wrong with this code? [ SOLVED ]

https://code.sololearn.com/WeeH0GREqrSW/?ref=app This is a code coach problem. It gives me output in code playground but not in code coach. What went wrong in this code. Pls help me ( Javascript code coach - important reminders). I have mentioned about the task in brackets. The code coach problem is in function parameter lesson of javascript. Here is the problem 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

25th Oct 2020, 10:24 AM
Tushita Priya
Tushita Priya - avatar
43 Antworten
+ 14
function main() { var eventExample = readLine(); // function call setReminder(eventExample) } //complete the function function setReminder(eventExample) { message = "You set a reminder about" + " " + eventExample; console.log(message); }
9th Jul 2021, 6:17 PM
Aziz Ergashev
Aziz Ergashev - avatar
+ 3
Use prompt method in order to get user input Code: //////////////////// var input = prompt("Enter something"); // function call if (input == "") { input = "workout" setReminder(input); } else { setReminder(input); } //complete the function function setReminder(name){ alert("You set a remainder about " + name); }
25th Oct 2020, 2:33 PM
sarfaraz mir
sarfaraz mir - avatar
+ 3
1. "CODE COACH" only accept console function.. that print, read console line, throw error and exception about your program.. 2. You didn't put the read console line function in your code.. and print the result in the wrong way.. 3. For reading console line you need "readline()" function.. And for print it in your console, use "console.log(value)" Example: //use readline to variable that you want to use var str = readline(); //this will return string var i = parseInt(readline()); //this will return integer if you don't put another string except number and decimal point declaration //use console log to print everything to the console console.log(str); //this will print string console.log(i); //this will print number var txt = str + i; //this will convert every number into string and combine it into the string if the string declared first console.log(txt); //this will print string var sum = i + 5; console.log(sum); //this will print number Input: Hello World! 10 Output: Hello World! 10 Hello World!10 15 :>
27th Oct 2020, 8:04 AM
El Roy Situmorang
+ 2
Abhay He means the task in these lessons(2nd page). https://www.sololearn.com/learn/JavaScript/1146/ It is considered code coach in SoloLearn. The input doesn't have space before the word. You need to add space after the sentence.
25th Oct 2020, 10:35 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
function main() { var eventExample = readLine(); // function call setReminder(eventExample) } //complete the function function setReminder(eventExample) { console.log("You set a reminder about" + " " +eventExample) }; hope it helps
7th Jul 2021, 10:54 AM
snipher marube
snipher marube - avatar
+ 1
Tushita Priya remove last 3 lines , "reminder" is not spelled as remainder, use console.log , adjust for single space after "about " should work now 👍
25th Oct 2020, 12:31 PM
Daljeet Singh
Daljeet Singh - avatar
+ 1
function main() { var eventExample = readLine(); // function call setReminder(eventExample) } //complete the function function setReminder(eventExample) { message = "You set a reminder about" + " " + eventExample; console.log(message); };
6th May 2021, 1:25 PM
Donald
+ 1
function main() { var eventExample = readLine(); // function call setReminder(eventExample) } //complete the function function setReminder(eventExample) { console.log("You set a reminder about "+eventExample) };
17th May 2021, 1:26 AM
Sebastián García
Sebastián García - avatar
+ 1
function main() { var eventExample = readLine(); // function call setReminder(eventExample) } //complete the function function setReminder(a) {console.log("You set a reminder about " + a)}
14th Sep 2021, 9:51 PM
Matthew
+ 1
function main() { var eventExample = readLine(); // function call setReminder(eventExample) } //complete the function function setReminder(eventExample) { console.log(`You set a reminder about ${eventExample}`) };
28th Aug 2022, 11:43 AM
Sardorbek Olimov
Sardorbek Olimov - avatar
0
What's your android version
25th Oct 2020, 10:31 AM
Tushita Priya
Tushita Priya - avatar
0
Maybe that's why u r not getting them. Your android version is old or it might be a glitch. Do you have new interface in the app. They changed the learn interface
25th Oct 2020, 10:34 AM
Tushita Priya
Tushita Priya - avatar
0
There is no method such as readLine() in node,I even Googled to make sure there is no method like it ,however node has one such as readline() module for input output stuff, https://www.google.com/url?sa=t&source=web&rct=j&url=https://nodejs.org/api/readline.html&ved=2ahUKEwj6z5rfxs_sAhWZzzgGHeo8ChUQFjACegQICxAB&usg=AOvVaw1kx1u0u8EqUN9WwYIxiNH7&cshid=1603622590541 The code you are trying isn't for Javascript in browser , The code playground used for the above code coach is node which is Javascript runtime environment used for execution of JavaScript outside browser , probably node is calling main method itself and therefore any other function call inside it executes (If someone knows that there is really a method readLine() like used in the above code coach let me know )
25th Oct 2020, 10:51 AM
Abhay
Abhay - avatar
0
Tushita Priya I don't know what you are talking about Java ,but Java and JavaScript are different ,if you think there is readLine method in JavaScript and node can you provide a link?
25th Oct 2020, 11:08 AM
Abhay
Abhay - avatar
0
alert works well in js ,can you show what you are trying? alert isn't available in node tho
25th Oct 2020, 11:25 AM
Abhay
Abhay - avatar
0
You need to call main function and you don't have readLine method.
26th Oct 2020, 1:55 AM
FrankoS
0
Thanks a lot for aiding and supporting me.
26th Oct 2020, 4:49 PM
Tushita Priya
Tushita Priya - avatar
0
M*S €(^-^() I tried using console.log too but it's the same result
27th Oct 2020, 1:52 AM
Tushita Priya
Tushita Priya - avatar
0
Matteo Rocco Micò yeah it is working well in playground but it is not in codecoach
27th Oct 2020, 1:55 AM
Tushita Priya
Tushita Priya - avatar
0
U can use document.write instead of console.log to get output on screen
27th Oct 2020, 1:20 PM
Vral Vyas