Loose vs Strict
JavaScript
Easy
6 views
Problem Description
Two JSON values are given on two lines: a and b. Print two words: the result of (a == b) and (a === b) as YES/NO.
Input Format
Line1: JSON value a. Line2: JSON value b.
Output Format
One line: loose strict.
Constraints
Inputs are valid JSON.
Official Solution
const fs=require('fs');const txt=fs.readFileSync(0,'utf8');const lines=txt.split(/\
?\
/);const aLine=(lines[0]??'').trim();const bLine=lines.slice(1).join('\
').trim();if(!aLine||!bLine)process.exit(0);const a=JSON.parse(aLine);const b=JSON.parse(bLine);const loose=(a==b);const strict=(a===b);process.stdout.write((loose?'YES':'NO')+' '+(strict?'YES':'NO'));
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!