+ 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
43 Respostas
+ 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);
}
+ 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);
}
+ 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
:>
+ 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.
+ 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
+ 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 👍
+ 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);
};
+ 1
function main() {
var eventExample = readLine();
// function call
setReminder(eventExample)
}
//complete the function
function setReminder(eventExample) {
console.log("You set a reminder about "+eventExample)
};
+ 1
function main() {
var eventExample = readLine();
// function call
setReminder(eventExample)
}
//complete the function
function setReminder(a) {console.log("You set a reminder about " + a)}
+ 1
function main() {
var eventExample = readLine();
// function call
setReminder(eventExample)
}
//complete the function
function setReminder(eventExample) {
console.log(`You set a reminder about ${eventExample}`)
};
0
What's your android version
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
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 )
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?
0
alert works well in js ,can you show what you are trying?
alert isn't available in node tho
0
You need to call main function and you don't have readLine method.
0
Thanks a lot for aiding and supporting me.
0
M*S €(^-^() I tried using console.log too but it's the same result
0
Matteo Rocco Micò yeah it is working well in playground but it is not in codecoach
0
U can use document.write instead of console.log to get output on screen