Skip to content

Instantly share code, notes, and snippets.

@joefearnley
Created July 2, 2020 13:08
Show Gist options
  • Save joefearnley/077c2179d14527cdaf5f173ddbac61c8 to your computer and use it in GitHub Desktop.
Save joefearnley/077c2179d14527cdaf5f173ddbac61c8 to your computer and use it in GitHub Desktop.
The 10-Day JS Challenge - Day 8: First Digit
const firstDigit = str => str.split('').filter(s =>!isNaN(s))[0];
describe('firstDigit()', () => {
it('return the first digit in a string', () => {
// arrange
const str = "var_1__Int2";
// act
const result = firstDigit(str);
// log
console.log("result: ", result);
// assert
expect(result).toBe('1');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment