From bba7a165974a25302edbd80104b0da0148abd625 Mon Sep 17 00:00:00 2001 From: jxrt Date: Tue, 23 Aug 2022 11:38:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=A8=E5=A4=A7?= =?UTF-8?q?=E6=95=B0=E7=9B=B8=E5=8A=A0=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/add.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/add.js b/lib/add.js index 1714b95..ccc3f89 100644 --- a/lib/add.js +++ b/lib/add.js @@ -1,5 +1,19 @@ -function add() { +function add(n1,n2) { // 实现该函数 + const n1Arr = n1.split('') + const n2Arr = n2.split('') + const resultArr = []; + let count = 0; + const maxLength = n1Arr.length>n2Arr.length?n1Arr.length:n2Arr.length + for(let i=maxLength-1;i>=0;i--){ + const sum = Number(n1Arr[i])+Number(n2Arr[i])+count; + resultArr.unshift(sum%10) + count = sum>9?1:0 + } + if(count>0){ + resultArr.unshift(count) + } + return resultArr.join('') } module.exports = add \ No newline at end of file From 6ec00bbc395ce57f00d55c563887595e24ee3221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=81=E4=BD=B3=E8=AF=9A?= <604047772@qq.com> Date: Tue, 23 Aug 2022 14:01:07 +0800 Subject: [PATCH 2/2] Create github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/github-actions-demo.yml diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml new file mode 100644 index 0000000..75be101 --- /dev/null +++ b/.github/workflows/github-actions-demo.yml @@ -0,0 +1,17 @@ +name: GitHub Actions Demo +on: [push] +jobs: + Explore-GitHub-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v3 + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository + run: | + ls ${{ github.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}."