Skip to content

Commit 02279f5

Browse files
authored
Create 2490-circular-sentence.js
1 parent 661eb3c commit 02279f5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

2490-circular-sentence.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {string} sentence
3+
* @return {boolean}
4+
*/
5+
var isCircularSentence = function(sentence) {
6+
const arr = sentence.split(' ')
7+
const n = arr.length
8+
for(let i = 0; i < n; i++) {
9+
if(i === n - 1) {
10+
if(arr[i][arr[i].length - 1] !== arr[0][0]) return false
11+
} else {
12+
if(arr[i][arr[i].length - 1] !== arr[i + 1][0]) return false
13+
}
14+
}
15+
return true
16+
};

0 commit comments

Comments
 (0)