본문 바로가기
알고리즘/Codewars

[Codewars] Regexp Basics - is it a digit? (8 kyu) / JavaScript

by fluss 2023. 4. 30.

https://www.codewars.com/kata/567bf4f7ee34510f69000032

 

Codewars - Achieve mastery through coding practice and developer mentorship

A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!

www.codewars.com

 

DESCRIPTION:

Implement String#digit? (in Java StringUtils.isDigit(String)), which should return true if given object is a digit (0-9), false otherwise.

 

코드

String.prototype.digit = function() {
  return /^\d{1}$/.test(this);
};

댓글