<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
</body>
<script>
// 这里要达到的效果是显示word中所有y的索引
var word = "Telling people you’re tired, when in reality, you’re just sad."
function ceshi() {
var a = word.split('');
for (let i = 0; i < a.length; i++) {
if (a[i+ 1] == "o" && a[i] == "y") {
console.log(i);
}
}
}
ceshi(word);
</script>
</html>