Anagram Check — Input Parsing

Node.js Published Updated 0 Views Verified
Node.js Coding Challenge — Anagram Check (Input Parsing). You are building a small JavaScript/Node.js utility. Read the value from a string/CLI-style input, convert it to the correct type and produce the answer. Explain the logic briefly and provide runnable Node.js code. The solution must avoid accidental string-number concatenation and should behave predictably for normal input.
Looking for the latest Sarkari Result 2026 updates? Check the latest government exam results, merit lists and result updates on Sarkari Resultess.
Sarkari Resultess
Questions & Answers

Answer & Explanation

4 Answers
Verified

Possible but Incorrect Code

function anagram(a,b){var norm=s=>s.toLowerCase().replace(/\s/g,'').split('').sort().join('');return norm(a)===norm(b)} console.log(anagram('listen','silent'));
Additional Explanation
यह option जानबूझकर एक common bug/unsafe approach दिखाता है। इसे production solution के रूप में इस्तेमाल करने से पहले variable scope, async flow, module path, validation, error handling और security checks verify करें। ऊपर दिए गए correct option से exact difference compare करें.
Sarkari Resultess
Editorial Answer 1
Verified Correct Answer

Correct Code / Solution

function anagram(a,b){const norm=s=>s.toLowerCase().replace(/\s/g,'').split('').sort().join('');return norm(a)===norm(b)} console.log(anagram('listen','silent'));
Additional Explanation
This solution implements Anagram Check using standard JavaScript/Node.js syntax. Keep numeric inputs as numbers, validate boundary cases when the problem requires it, and return a value from reusable functions instead of mixing calculation with output.
Sarkari Resultess
Editorial Answer 2
Verified

Possible but Incorrect Code

function anagram(a,b){const norm=s=>s.toLowerCase().replace(/\s/g,'').split('').sort().join('');return norm(a)==norm(b)} console.log(anagram('listen','silent'));
Additional Explanation
यह option जानबूझकर एक common bug/unsafe approach दिखाता है। इसे production solution के रूप में इस्तेमाल करने से पहले variable scope, async flow, module path, validation, error handling और security checks verify करें। ऊपर दिए गए correct option से exact difference compare करें.
Sarkari Resultess
Editorial Answer 3
Verified

Possible but Incorrect Code

function anagram(a,b){const norm=s=>s.toLowerCase().replace(/\s/g,'').split('').sort().join('');return String(norm(a)===norm(b)} console.log(anagram('listen','silent'));
Additional Explanation
यह option जानबूझकर एक common bug/unsafe approach दिखाता है। इसे production solution के रूप में इस्तेमाल करने से पहले variable scope, async flow, module path, validation, error handling और security checks verify करें। ऊपर दिए गए correct option से exact difference compare करें.
Sarkari Resultess
Editorial Answer 4