feat(client, learn): add helper functions for common validation operations (#38605)
Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
This commit is contained in:
@ -41,7 +41,7 @@ tests:
|
||||
- text: <code>substringDivisibility()</code> should return [ 1430952867, 1460357289, 1406357289, 4130952867, 4160357289, 4106357289 ].
|
||||
testString: assert.sameMembers(substringDivisibility(), [ 1430952867, 1460357289, 1406357289, 4130952867, 4160357289, 4106357289 ]);
|
||||
- text: You should not copy and return the array.
|
||||
testString: assert(!removeJSComments(code).match(/(1430952867)|(1460357289)|(1406357289)|(4130952867)|(4160357289)|(4106357289)/))
|
||||
testString: assert(!__helpers.removeJSComments(code).match(/(1430952867)|(1460357289)|(1406357289)|(4130952867)|(4160357289)|(4106357289)/))
|
||||
|
||||
```
|
||||
|
||||
@ -63,15 +63,6 @@ substringDivisibility();
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
@ -77,7 +77,7 @@ function isValid(iban) {
|
||||
MC:27, MR:27, SM:27, AL:28, AZ:28, CY:28, DO:28, GT:28,
|
||||
HU:28, LB:28, PL:28, BR:29, PS:29, KW:30, MU:30, MT:31
|
||||
}
|
||||
iban = iban.replace(/\s/g, '')
|
||||
iban = __helpers.removeWhiteSpace(iban)
|
||||
if (!iban.match(/^[\dA-Z]+$/)) return false
|
||||
var len = iban.length
|
||||
if (len != ibanLen[iban.substr(0,2)]) return false
|
||||
|
@ -66,7 +66,7 @@ function solve(input) {
|
||||
function solve(input) {
|
||||
var orig = {};
|
||||
input.forEach(function(e) {
|
||||
orig[e.replace(/\s/g, '').toLowerCase()] = e;
|
||||
orig[__helpers.removeWhiteSpace(e).toLowerCase()] = e;
|
||||
});
|
||||
|
||||
input = Object.keys(orig);
|
||||
|
Reference in New Issue
Block a user