1.

What is the code to be used to trim whitespaces?(a) let trimmed = (l.trim() for (l in lines));(b) let trimmed = (trim(l));(c) let trimmed = l.trim();(d) let trimmed = for(l in lines));This question was addressed to me in an interview for job.Query is from Shorthand functions and Multiple catch clauses topic in section Classes and Modules in JavaScript of JavaScript

Answer»

The correct OPTION is (a) let trimmed = (l.TRIM() for (l in lines));

Best EXPLANATION: The various types of trim functions are trimLeft(), trimRight() and trim().can use the above code to trim whitespaces and FILTER out comments and blank lines.



Discussion

No Comment Found

Related InterviewSolutions