isOnlyWhitespace.js 410 B

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