I struggle to figure out the reason why I got SyntaxError: Unexpected token '{' in node.js
I struggle to figure out the reason why I got SyntaxError: Unexpected token '{' in node.js
我正在学习基础知识 Javascript,但由于语法错误而陷入这个简单的错误。
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
let a;
let b;
// let C;
rl.on('line', (line) => {
input = line.split(' ');
}).on('close', () => {
a = input[0];
b = input[1];
if (a < b) {
console.log('<');
}else if (a > b) {
console.log('>');
}else (a == b) {
console.log('=');
};
});
// 1 2
在 else 语句中不能放置条件。用以下代码替换您的代码。
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
let a;
let b;
// let C;
rl.on('line', (line) => {
input = line.split(' ');
}).on('close', () => {
a = input[0];
b = input[1];
if (a < b) {
console.log('<');
}else if (a > b) {
console.log('>');
}else {
console.log('=');
};
});
希望对你有帮助!! XD
我正在学习基础知识 Javascript,但由于语法错误而陷入这个简单的错误。
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
let a;
let b;
// let C;
rl.on('line', (line) => {
input = line.split(' ');
}).on('close', () => {
a = input[0];
b = input[1];
if (a < b) {
console.log('<');
}else if (a > b) {
console.log('>');
}else (a == b) {
console.log('=');
};
});
// 1 2
在 else 语句中不能放置条件。用以下代码替换您的代码。
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
let a;
let b;
// let C;
rl.on('line', (line) => {
input = line.split(' ');
}).on('close', () => {
a = input[0];
b = input[1];
if (a < b) {
console.log('<');
}else if (a > b) {
console.log('>');
}else {
console.log('=');
};
});
希望对你有帮助!! XD