Move History

Rooted by: Last Char
Fork Selected
  • Strings
    Data 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')
           });
    });
  • Code
    • let lastChar = string => string[string.length - 1]
    • let lastChar = string => string.slice(-1)