-
StringsData Types
Code let lastChar = string => string.slice(-1)
Preloaded Code // is this the place where you can build your module and export it ?
Test Cases describe("basic test", function(){ var domain='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', lC=(t)=>t.slice(-1); const randomString=(length, chars)=>{ var result = ''; for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)]; return result; } var rString=randomString(Math.floor(Math.random() * (domain.length - 1 + 1)) +1,domain) console.log(rString,lastChar(rString)) it ("Test passed",()=>{ Test.assertEquals(lastChar(rString), lC(rString), 'Test passed') }); });
Output:
-
Code let lastChar = string => string[string.length - 1]- let lastChar = string => string.slice(-1)
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}