Free webinar! How to Make Generative AI Work for You
Get my free ticket+ 1
What is wrong? Error on test.
6 Answers
+ 3
Could you please describe what the code is supposed to do?
According to the error message, we can't use prompt() in the node.js script. If it is a sololearn code task, use the given code to get input.
+ 2
Worked. Thx for all) Prompt - is a title of function:
const prompt = (function() {
const lines = require('fs').readFileSync(0, 'utf8').split('\n')
return function() {
if (lines.length > 0)
return lines.shift()
const error = Error('EOF when reading a line')
error.name = 'EOFError'
throw error
}
})()
+ 1
prompt function doesn't works in Node js
use readLine function
+ 1
let x = Number(prompt())
let y = Number(prompt())
let a = ''
for(x; x <= y; x++){
if (Number.isInteger(Math.sqrt(x))){
a = a + " " + x
}
}
console.log(a)
0
Use Web playground's JavaScript tab for running JS code..
0
This is a task from another course.
Machine translate:
"Input data
Integers a and b are entered. It is guaranteed that a does not exceed b.
Output
Print all numbers on the segment from a to b that are perfect squares. If there are no such numbers, then nothing needs to be output."