Splitting Two Strings with Half-width Spaces

Asked 1 years ago, Updated 1 years ago, 278 views

Divide two strings by half-width space (equivalent to paiza rank D)

Attempt to run with split method results in an error.
Please let me know.

process.stdin.resume();
process.stdin.setEncoding('utf8');

varlines=[];
var reader=require('readline').createInterface({
  input:process.stdin,
  output —process.stdout
});
reader.on('line',(line)=>{
  lines.push(line);
});
reader.on('close',()=>{
  
  for (varwords of values) {
       var values = words.split('lines');

      console.log(values);
  }
 
});

javascript

2022-11-09 09:05

1 Answers

If you look at the script, lines is defined as var lines=[];, while for(var words of values){ uses undefined values.This is likely to cause values is not possible errors.I thought this might be a error.Therefore, please correct it as below and try again.

From:

 for (var words of values) {

To:

 for (var words of lines) {


2022-11-09 09:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.