my codeacademy course
来源:互联网 发布:她理财是否可靠 知乎 编辑:程序博客网 时间:2024/06/05 11:40
/*jshint multistr:true */
var text = "chendan good huangqian chenyihan huangyucai \
huangqian chenshuang \
chuanzhiping wanglingling chendan chenyihan google";
var myName = "chendan";
var tmp = [];
var hits = [];
Array.prototype.compare = function (array) {
// if the other array is a falsy value, return
if (!array)
return false;
// compare lengths - can save a lot of time
if (this.length != array.length)
return false;
for (var i = 0, l=this.length; i < l; i++) {
// Check if we have nested arrays
if (this[i] instanceof Array && array[i] instanceof Array) {
// recurse into the nested arrays
if (!this[i].compare(array[i]))
return false;
}
else if (this[i] != array[i]) {
// Warning - two different object instances will never be equal: {x:20} != {x:20}
return false;
}
}
return true;
}
for(var i=0;i< text.length;i++){
tmp.push(text[i]);
if(tmp.compare(['c','h','e','n','d','a','n']) === true){
console.log("you get it!");
for(j=0;j<7;j++){
hits.push(tmp.shift());
}
tmp=[];
}else if(tmp.length === 7){
tmp.shift();
}
}
if(hits === []){
console.log("Your name wasn't found!");
}else{
console.log(hits);
}
var text = "chendan good huangqian chenyihan huangyucai \
huangqian chenshuang \
chuanzhiping wanglingling chendan chenyihan google";
var myName = "chendan";
var tmp = [];
var hits = [];
Array.prototype.compare = function (array) {
// if the other array is a falsy value, return
if (!array)
return false;
// compare lengths - can save a lot of time
if (this.length != array.length)
return false;
for (var i = 0, l=this.length; i < l; i++) {
// Check if we have nested arrays
if (this[i] instanceof Array && array[i] instanceof Array) {
// recurse into the nested arrays
if (!this[i].compare(array[i]))
return false;
}
else if (this[i] != array[i]) {
// Warning - two different object instances will never be equal: {x:20} != {x:20}
return false;
}
}
return true;
}
for(var i=0;i< text.length;i++){
tmp.push(text[i]);
if(tmp.compare(['c','h','e','n','d','a','n']) === true){
console.log("you get it!");
for(j=0;j<7;j++){
hits.push(tmp.shift());
}
tmp=[];
}else if(tmp.length === 7){
tmp.shift();
}
}
if(hits === []){
console.log("Your name wasn't found!");
}else{
console.log(hits);
}
0 0
- my codeacademy course
- 1005 the PygLatin-codeacademy
- 【Bash】codeacademy笔记
- Course
- course
- 207. Course Schedule My SubmissionsQuestionEditorial Solution【M】【48】【vip】【再来一遍】
- Codeacademy Python-06-Student Becomes the Teacher
- Codeacademy Python-07-Student Becomes the Teacher
- Codeacademy Python-12-File Input/Output
- My
- MY
- MY
- MY
- my
- my
- my
- my
- my
- MongoDB学习之旅一:走进MongoDB世界
- char * 与char []的区别
- Hopfield神经网络
- jquery validate addMethod 及时间验证08:00-10:00
- apache 本地配置虚拟主403错误的解决方法
- my codeacademy course
- 【LeetCode】Climbing Stairs
- 黑马程序员 自学08C#编程基础之循环复习
- close() was never explicitly called on database 和 database is locked 错误原因
- 项目6-人数不定的工资类
- UVA 11462 Age Sort
- 将resultSet转换为list(jdbc sql获取rs)
- 英荷两国政府向微软付费以延伸XP撑持协议
- 【杂症】一个豌豆荚引发的血案——关于ADB server didn't ACK的问题