def pin_validator(pin): return len(str(pin)) == 5 and str(pin).isdigit()
function pinValidator(pin) {var pinLength = pin.length;var pinIsCorrect = (pinLength === 4 || pinLength === 6);var onlyNumbers = pin.match (/^\d+$/);if (pinIsCorrect && onlyNumbers){return true;console.log("TRUE");}else {return false;console.log("FALSE");}};pinValidator('88888');- def pin_validator(pin):
- return len(str(pin)) == 5 and str(pin).isdigit()
# TODO: Replace examples and use TDD by writing your own tests # These are some of the methods available: # test.expect(boolean, [optional] message) # test.assert_equals(actual, expected, [optional] message) # test.assert_not_equals(actual, expected, [optional] message) # You can use Test.describe and Test.it to write BDD style test groupings test.assert_equals(pin_validator(13453), True) test.assert_not_equals(pin_validator(3353), True)
// TODO: Add your tests here// Starting from Node 10.x, [Mocha](https://mochajs.org) is used instead of our custom test framework.// [Codewars' assertion methods](https://github.com/Codewars/codewars.com/wiki/Codewars-JavaScript-Test-Framework)// are still available for now.//// For new tests, using [Chai](https://chaijs.com/) is recommended.// You can use it by requiring:// const assert = require("chai").assert;// If the failure output for deep equality is truncated, `chai.config.truncateThreshold` can be adjusted.- # TODO: Replace examples and use TDD by writing your own tests
- # These are some of the methods available:
- # test.expect(boolean, [optional] message)
- # test.assert_equals(actual, expected, [optional] message)
- # test.assert_not_equals(actual, expected, [optional] message)
describe("Solution", function() {it("should test for something", function() {// Test.assertEquals(1 + 1, 2);// assert.strictEqual(1 + 1, 2);});});- # You can use Test.describe and Test.it to write BDD style test groupings
- test.assert_equals(pin_validator(13453), True)
- test.assert_not_equals(pin_validator(3353), True)