Skip to content

Commit

Permalink
null line reduction #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ramyaragupathy committed Feb 16, 2018
1 parent 20c31db commit 9b10288
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env node
const fs = require('fs')
const parser = require('./src/parser.js')
const fileName = process.argv[2]
Expand All @@ -13,7 +12,7 @@ if (jsonStr === null) {
} else if (jsonStr[1] !== '') {
jsonStr[1] = jsonStr[1].trim()
if (jsonStr[1] !== '') {
console.log(message[0], jsonStr[1])
console.log(message[0])
} else {
console.log(jsonStr[0])
}
Expand Down
6 changes: 2 additions & 4 deletions src/parser.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env node
const nullParser = (input) => {
let nullValue = input.slice(0, 4)
if (nullValue === 'null') {
input = input.slice(4, input.length)
return [null, input]
if (input.startsWith('null')) {
return [null, input.slice(4, input.length)]
} else return null
}

Expand Down

0 comments on commit 9b10288

Please sign in to comment.