isOnlyWhitespace.js 357 B

12345678910111213141516171819
  1. 'use strict';
  2. const isWhitespace = require('./isWhitespace');
  3. /**
  4. * Returns a Boolean indicating whether the input string is only whitespace.
  5. *
  6. * @param {string} input
  7. * @returns {boolean}
  8. */
  9. module.exports = function isOnlyWhitespace(input) {
  10. for (const element of input) {
  11. if (!isWhitespace(element)) {
  12. return false;
  13. }
  14. }
  15. return true;
  16. };