Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter01下的experience1.md中格式有问题 #36

Open
nadirvishun opened this issue Apr 25, 2022 · 1 comment
Open

Chapter01下的experience1.md中格式有问题 #36

nadirvishun opened this issue Apr 25, 2022 · 1 comment

Comments

@nadirvishun
Copy link

nadirvishun commented Apr 25, 2022

刚开始看第一张,非常棒,但在Chapter01/experience1.md中有点瑕疵:

``javascript
var sumOfNums = 0, sumOfSet = 0;
var set = new Set();
for (var i = 0; i < nums[i]; i++) {
   if (set.has(nums[i])) {
       sumOfSet += nums[i];
  } else {
       set.add(nums[i]);
       sumOfNums += nums[i];
  }
}

上方javascript前方只有两个`导致后面整体格式都不对了,而且功能也不全,应该改成:

var sumOfNums = 0, sumOfSet = 0;
var set = new Set();
for (var i = 0; i < nums.length; i++) {
   if (!set.has(nums[i])) {
       set.add(nums[i]);
       sumOfSet += nums[i];
  }
  sumOfNums += nums[i]
}
return sumOfSet * 2 - sumOfNums ;

或者是:

var sumOfNums = 0, sumOfSet = 0;
var set = new Set();
for (var i = 0; i < nums.length; i++) {
   if (set.has(nums[i])) {
       sumOfSet += nums[i] * 2;
  } else {
       set.add(nums[i]);
  }
  sumOfNums += nums[i];
}
return sumOfNums - sumOfSet;

由于没法fork,也没法提pr,所以提在issue中。

@FHfirehuo
Copy link
Owner

谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants