-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge_32_test.js
More file actions
33 lines (28 loc) · 830 Bytes
/
Copy pathchallenge_32_test.js
File metadata and controls
33 lines (28 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
Challenge 32; TRAILING STRING
There are two strings: A and B.
Print 1 if string B occurs at the end of string A.
Otherwise, print 0.
*/
var expect = require('chai').expect;
function isTrailing(a,b) {
var l = b.length;
return a.slice(0 - l) === b ? 1 : 0;
}
describe('isTrailing()', function(){
it('should be 1', function(){
expect( isTrailing("Hello World", "World") ).to.be.equal(1);
});
it('should be 1', function(){
expect( isTrailing("Hello CodeEval", "CodeEval") ).to.be.equal(1);
});
it('should be 0', function(){
expect( isTrailing("San Francisco", "San Jose") ).to.be.equal(0);
});
it('should be 1', function(){
expect( isTrailing("World", "World") ).to.be.equal(1);
});
it('should be 0', function(){
expect( isTrailing("Wor", "World") ).to.be.equal(0);
});
});