JS10. 计数器
描述
请补全JavaScript代码,要求每次调用函数"closure"时会返回一个新计数器。每当调用某个计数器时会返回一个数字且该数字会累加1。HTML/CSS/JavaScript 解法, 执行用时: 1678ms, 内存消耗: 77812KB, 提交时间: 2022-02-10
{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n <head>\n <meta charset=utf-8>\n </head>\n <body>\n \t\n <script type=\"text/javascript\">\n const closure = () => {\n // 补全代码\n let count = 0\n return function() {\n count++\n return count\n }\n }\n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1682ms, 内存消耗: 77800KB, 提交时间: 2022-02-10
{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n <head>\n <meta charset=utf-8>\n </head>\n <body>\n \t\n <script type=\"text/javascript\">\n const closure = () => {\n // 补全代码\n let count = 0;\n return function(){\n count++;\n return count\n }\n \n }\n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1693ms, 内存消耗: 77772KB, 提交时间: 2022-02-08
{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n <head>\n <meta charset=utf-8>\n </head>\n <body>\n \t\n <script type=\"text/javascript\">\n const closure = () => {\n // 补全代码\n let r = 0\n return function(){\n r++\n return r\n }\n }\n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1695ms, 内存消耗: 77772KB, 提交时间: 2022-02-09
{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n <head>\n <meta charset=utf-8>\n </head>\n <body>\n \t\n <script type=\"text/javascript\">\n const closure = () => {\n // 补全代码\n let count = 1;\n return function () {\n return count++\n }\n }\n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1695ms, 内存消耗: 77816KB, 提交时间: 2022-02-08
{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n <head>\n <meta charset=utf-8>\n </head>\n <body>\n \t\n <script type=\"text/javascript\">\n const closure = () => {\n // 补全代码\n var number = 0\n return () => ++number\n }\n </script>\n </body>\n</html>","libs":[]}