Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
js.js 11.66 KB
Copy Edit Raw Blame History
老胡来也 authored 2020年04月30日 10:40 +08:00 . JavaScript课程
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778
'use strict'
/*
1、题目描述
找出元素 item 在给定数组 arr 中的位置
输出描述:
如果数组中存在 item,则返回元素在数组中的位置,否则返回 -1
示例1
输入
[ 1, 2, 3, 4 ], 3
输出
2
function indexOf(arr, item) {
}
*/
/*
2、题目描述
计算给定数组 arr 中所有元素的总和
输入描述:
数组中的元素均为 Number 类型
示例1
输入
[ 1, 2, 3, 4 ]
输出
10
function sum(arr) {
}
*/
/*
3、题目描述
移除数组 arr 中的所有值与 item 相等的元素。不要直接修改数组 arr,结果返回新的数组
示例1
输入
[1, 2, 3, 4, 2], 2
输出
[1, 3, 4]
function remove(arr, item) {
}
*/
/*
4、题目描述
移除数组 arr 中的所有值与 item 相等的元素,直接在给定的 arr 数组上进行操作,并将结果返回
示例1
输入
[1, 2, 2, 3, 4, 2, 2], 2
输出
[1, 3, 4]
function removeWithoutCopy(arr, item) {
}
*/
/*
5、题目描述
在数组 arr 末尾添加元素 item。不要直接修改数组 arr,结果返回新的数组
示例1
输入
[1, 2, 3, 4], 10
输出
[1, 2, 3, 4, 10]
function append(arr, item) {
}
*/
/*
6、题目描述
删除数组 arr 最后一个元素。不要直接修改数组 arr,结果返回新的数组
示例1
输入
[1, 2, 3, 4]
输出
[1, 2, 3]
function truncate(arr) {
}
*/
/*
7、题目描述
在数组 arr 开头添加元素 item。不要直接修改数组 arr,结果返回新的数组
示例1
输入
[1, 2, 3, 4], 10
输出
[10, 1, 2, 3, 4]
function prepend(arr, item) {
}
*/
/*
8、题目描述
删除数组 arr 第一个元素。不要直接修改数组 arr,结果返回新的数组
示例1
输入
[1, 2, 3, 4]
输出
[2, 3, 4]
function curtail(arr) {
}
*/
/*
9、题目描述
合并数组 arr1 和数组 arr2。不要直接修改数组 arr,结果返回新的数组
示例1
输入
[1, 2, 3, 4], ['a', 'b', 'c', 1]
输出
[1, 2, 3, 4, 'a', 'b', 'c', 1]
function concat(arr1, arr2) {
}
*/
/*
10、题目描述
在数组 arr 的 index 处添加元素 item。不要直接修改数组 arr,结果返回新的数组
示例1
输入
[1, 2, 3, 4], 'z', 2
输出
[1, 2, 'z', 3, 4]
function insert(arr, item, index) {
}
*/
/*
11、题目描述
统计数组 arr 中值等于 item 的元素出现的次数
示例1
输入
[1, 2, 4, 4, 3, 4, 3], 4
输出
3
function count(arr, item) {
}
*/
/*
12、题目描述
找出数组 arr 中重复出现过的元素
示例1
输入
[1, 2, 4, 4, 3, 3, 1, 5, 3]
输出
[1, 3, 4]
function duplicates(arr) {
}
*/
/*
13、题目描述
为数组 arr 中的每个元素求二次方。不要直接修改数组 arr,结果返回新的数组
示例1
输入
[1, 2, 3, 4]
输出
[1, 4, 9, 16]
function square(arr) {
}
*/
/*
14、题目描述
在数组 arr 中,查找值与 item 相等的元素出现的所有位置
示例1
输入
['a','b','c','d','e','f','a','b','c'] 'a'
输出
[0, 6]
function findAllOccurrences(arr, target) {
}
*/
/*
15、题目描述
给定的 js 代码中存在全局变量,请修复
function globals() {
myObject = {
name : 'Jory'
};
return myObject;
}
*/
/*
16、题目描述
请修复给定的 js 代码中,函数定义存在的问题
示例1
输入
true
输出
a
function functions(flag) {
if (flag) {
function getValue() { return 'a'; }
} else {
function getValue() { return 'b'; }
}
return getValue();
}
*/
/*
17、题目描述
修改 js 代码中 parseInt 的调用方式,使之通过全部测试用例
示例1
输入
'12'
输出
12
示例2
输入
'12px'
输出
12
示例3
输入
'0x12'
输出
0
function parse2Int(num) {
return parseInt(num);
}
*/
/*
18、题目描述
判断 val1 和 val2 是否完全等同
function identity(val1, val2) {
}
*/
/*
19、题目描述
实现一个打点计时器,要求
1、从 start 到 end(包含 start 和 end),每隔 100 毫秒 console.log 一个数字,每次数字增幅为 1
2、返回的对象中需要包含一个 cancel 方法,用于停止定时操作
3、第一个数需要立即输出
function count(start, end) {
}
*/
/*
20、题目描述
实现 fizzBuzz 函数,参数 num 与返回值的关系如下:
1、如果 num 能同时被 3 和 5 整除,返回字符串 fizzbuzz
2、如果 num 能被 3 整除,返回字符串 fizz
3、如果 num 能被 5 整除,返回字符串 buzz
4、如果参数为空或者不是 Number 类型,返回 false
5、其余情况,返回参数 num
示例1
输入
15
输出
fizzbuzz
function fizzBuzz(num) {
}
*/
/*
21、题目描述
将数组 arr 中的元素作为调用函数 fn 的参数
示例1
输入
function (greeting, name, punctuation) {return greeting + ', ' + name + (punctuation || '!');}, ['Hello', 'Ellie', '!']
输出
Hello, Ellie!
function argsAsArray(fn, arr) {
}
*/
/*
22、题目描述
将函数 fn 的执行上下文改为 obj 对象
示例1
输入
function () {return this.greeting + ', ' + this.name + '!!!';}, {greeting: 'Hello', name: 'Rebecca'}
输出
Hello, Rebecca!!!
function speak(fn, obj) {
}
*/
/*
23、题目描述
实现函数 functionFunction,调用之后满足如下条件:
1、返回值为一个函数 f
2、调用返回的函数 f,返回值为按照调用顺序的参数拼接,拼接字符为英文逗号加一个空格,即 ', '
3、所有函数的参数数量为 1,且均为 String 类型
示例1
输入
functionFunction('Hello')('world')
输出
Hello, world
function functionFunction(str) {
}
*/
/*
24、题目描述
实现函数 makeClosures,调用之后满足如下条件:
1、返回一个函数数组 result,长度与 arr 相同
2、运行 result 中第 i 个函数,即 result[i](),结果与 fn(arr[i]) 相同
示例1
输入
[1, 2, 3], function (x) {
return x * x;
}
输出
4
function makeClosures(arr, fn) {
}
*/
/*
25、题目描述
已知函数 fn 执行需要 3 个参数。请实现函数 partial,调用之后满足如下条件:
1、返回一个函数 result,该函数接受一个参数
2、执行 result(str3) ,返回的结果与 fn(str1, str2, str3) 一致
示例1
输入
var sayIt = function(greeting, name, punctuation) { return greeting + ', ' + name + (punctuation || '!'); }; partial(sayIt, 'Hello', 'Ellie')('!!!');
输出
Hello, Ellie!!!
function partial(fn, str1, str2) {
}
*/
/*
26、题目描述
函数 useArguments 可以接收 1 个及以上的参数。请实现函数 useArguments,返回所有调用参数相加后的结果。本题的测试参数全部为 Number 类型,不需考虑参数转换。
示例1
输入
1, 2, 3, 4
输出
10
function useArguments() {
}
*/
/*
27、题目描述
实现函数 callIt,调用之后满足如下条件
1、返回的结果为调用 fn 之后的结果
2、fn 的调用参数为 callIt 的第一个参数之后的全部参数
示例1
输入
输出
function callIt(fn) {
}
*/
/*
28、题目描述
实现函数 partialUsingArguments,调用之后满足如下条件:
1、返回一个函数 result
2、调用 result 之后,返回的结果与调用函数 fn 的结果一致
3、fn 的调用参数为 partialUsingArguments 的第一个参数之后的全部参数以及 result 的调用参数
示例1
输入
输出
function partialUsingArguments(fn) {
}
*/
/*
29、题目描述
已知 fn 为一个预定义函数,实现函数 curryIt,调用之后满足如下条件:
1、返回一个函数 a,a 的 length 属性值为 1(即显式声明 a 接收一个参数)
2、调用 a 之后,返回一个函数 b, b 的 length 属性值为 1
3、调用 b 之后,返回一个函数 c, c 的 length 属性值为 1
4、调用 c 之后,返回的结果与调用 fn 的返回值一致
5、fn 的参数依次为函数 a, b, c 的调用参数
示例1
输入
var fn = function (a, b, c) {return a + b + c}; curryIt(fn)(1)(2)(3);
输出
6
function curryIt(fn) {
}
*/
/*
30、题目描述
返回参数 a 和 b 的逻辑或运算结果
示例1
输入
false, true
输出
true
function or(a, b) {
}
*/
/*
31、题目描述
返回参数 a 和 b 的逻辑且运算结果
示例1
输入
false, true
输出
false
function and(a, b) {
}
*/
/*
32、题目描述
完成函数 createModule,调用之后满足如下要求:
1、返回一个对象
2、对象的 greeting 属性值等于 str1, name 属性值等于 str2
3、对象存在一个 sayIt 方法,该方法返回的字符串为 greeting属性值 + ', ' + name属性值
function createModule(str1, str2) {
}
*/
/*
33、题目描述
获取数字 num 二进制形式第 bit 位的值。注意:
1、bit 从 1 开始
2、返回 0 或 1
3、举例:2 的二进制为 10,第 1 位为 0,第 2 位为 1
示例1
输入
128, 8
输出
1
function valueAtBit(num, bit) {
}
*/
/*
34、题目描述
给定二进制字符串,将其换算成对应的十进制数字
示例1
输入
'11000000'
输出
192
function base10(str) {
}
*/
/*
35、题目描述
将给定数字转换成二进制字符串。如果字符串长度不足 8 位,则在前面补 0 到满8位。
示例1
输入
65
输出
01000001
function convertToBinary(num) {
}
*/
/*
36、题目描述
求 a 和 b 相乘的值,a 和 b 可能是小数,需要注意结果的精度问题
示例1
输入
3, 0.0001
输出
0.0003
function multiply(a, b) {
}
*/
/*
37、题目描述
将函数 fn 的执行上下文改为 obj,返回 fn 执行后的值
示例1
输入
alterContext(function() {return this.greeting + ', ' + this.name + '!'; }, {name: 'Rebecca', greeting: 'Yo' })
输出
Yo, Rebecca!
function alterContext(fn, obj) {
}
*/
/*
38、题目描述
给定一个构造函数 constructor,请完成 alterObjects 方法,将 constructor 的所有实例的 greeting 属性指向给定的 greeting 变量。
示例1
输入
var C = function(name) {this.name = name; return this;};
var obj1 = new C('Rebecca');
alterObjects(C, 'What\'s up'); obj1.greeting;
输出
What's up
function alterObjects(constructor, greeting) {
}
*/
/*
39、题目描述
找出对象 obj 不在原型链上的属性(注意这题测试例子的冒号后面也有一个空格~)
1、返回数组,格式为 key: value
2、结果数组不要求顺序
示例1
输入
var C = function() {this.foo = 'bar'; this.baz = 'bim';};
C.prototype.bop = 'bip';
iterate(new C());
输出
["foo: bar", "baz: bim"]
function iterate(obj) {
}
*/
/*
40、题目描述
给定字符串 str,检查其是否包含数字,包含返回 true,否则返回 false
示例1
输入
'abc123'
输出
true
function containsNumber(str) {
}
*/
/*
41、题目描述
给定字符串 str,检查其是否包含连续重复的字母(a-zA-Z),包含返回 true,否则返回 false
示例1
输入
'rattler'
输出
true
function containsRepeatingLetter(str) {
}
*/
/*
42、题目描述
给定字符串 str,检查其是否以元音字母结尾
1、元音字母包括 a,e,i,o,u,以及对应的大写
2、包含返回 true,否则返回 false
示例1
输入
'gorilla'
输出
true
function endsWithVowel(str) {
}
*/
/*
43、题目描述
给定字符串 str,检查其是否包含 连续3个数字
1、如果包含,返回最新出现的 3 个数字的字符串
2、如果不包含,返回 false
示例1
输入
'9876543'
输出
987
function captureThreeNumbers(str) {
}
*/
/*
44、题目描述
给定字符串 str,检查其是否符合如下格式
1、XXX-XXX-XXXX
2、其中 X 为 Number 类型
示例1
输入
'800-555-1212'
输出
true
function matchesPattern(str) {
}
*/
/*
45、题目描述
给定字符串 str,检查其是否符合美元书写格式
1、以 $ 开始
2、整数部分,从个位起,满 3 个数字用 , 分隔
3、如果为小数,则小数部分长度为 2
4、正确的格式如:1,023,032ドル.03 或者 2ドル.03,错误的格式如:3,432,12ドル.12 或者 34,344ドル.3
示例1
输入
'20,933,209ドル.93'
输出
true
function isUSD(str) {
}
*/
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chewelve/javascript_course.git
git@gitee.com:chewelve/javascript_course.git
chewelve
javascript_course
JavaScript课程
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /