Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of elements. For example:
解法一 由于 string 和 array 都具有 length 属性,且都可通过 for 循环遍历,所以未判断数据结构
1 2 3 4 5 6 7 8 9
var uniqueInOrder=function(iterable){ let arr = [] for (let i = 0; i < iterable.length; i++) { if (iterable[i] !== iterable[i - 1]) { arr.push(iterable[i]) } } return arr }