六角學院
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 第十一關 函式參數再練習 小杰:「師傅你就老實承認吧..你是不是認識我老闆?」 小杰:「還有你教我的都是 JAVA 啊,害我還得自己轉成 JavaScript..」 師傅:「我跟你老闆認識 2、30 年了,還有這樣的訓練安排是我故意的,這樣以後你學其他的語言才會舉一反三,懂為師的安排嗎?」 小杰:「...可惡,原來你早就跟老闆串通好了,假借帶我變強,實則是借刀花自己的特休來教育訓練」 師傅:「呵呵呵..小毛頭這些都是人生歷練啊,想當年我...嗚!」 **剎那間,師傅手撫著胸跪了下來,表情逐漸扭曲痛苦。** 小杰焦急著問:「師傅你怎麼啦!?」 師傅:「快幫我叫救護車,我心臟的老毛病又犯了!」 過了 15 分鐘後,救護人員風風火火的過來了,但師傅仍然執拗的要小杰做完它提供的課題。 小杰:「師傅你不要再固執了啦,等你養好我們再鍛鍊不就好了!」 師傅:「不行!這題你一定要今天做完,不然我就不上救護車!」 小杰:「什麼東西啊..」 小杰抓抓了頭,焦急著左顧右盼,怎麼會有人這麼固執呢?於是他將眼神望向了醫護人員,希望他們一起說服師傅。 醫護人員:「他情況蠻緊急的,現在交通也很塞車,如果沒有在一小時內出發的話,我們不能擔保他的性命哦。」 師傅氣若游絲地說:「一小時綽綽有餘了...小杰你快做吧,你今天不完成...我向老闆承諾的學習進度就無法完成,我 30 年的吃飯借據就無法一筆勾銷了。」 小杰:「什麼!?你竟然吃了這麼久的霸王飯,竟然還順便利用了我,我真的衰到---」 醫護人員:「可以快一點做決定嗎?時間快來不及了!」 > 此時的小杰也無法做抉擇,身為遊戲玩家的你,你的選擇是? > A:不理師傅,安全第一,在救護車與醫院上再來慢慢研究 > B:非常不情願地在現場,嘗試在一小時內解完題目,順便挑戰自己的極限 # 題目 ## 題目一:老闆想要隨時扣你的薪水 老闆:「今天是發薪日,先發給你薪資 23500 元(遞給小杰」 老闆:「以下三步驟動作請寫成程式」 老闆:「步驟一:昨天你上廁所太久了,我要扣你 1000 元」 老闆:「步驟二:小黑說不喜歡你煮的狗食,我要再扣你 3500 元 (再次取走」 老闆:「步驟三:我今天心情不太好,扣個 500 元意思一下」 小杰:「屁啦!心情不太好關我啥事!」 老闆:「這不是重點,快點算!將之前的寫法換成函式,並增加一個參數,讓我方便何時扣你多少都沒問題」 老闆:「最後你寫的函式,要執行三次,每次都要回報你的總薪水剩下多少。」 [Codepen 範例程式碼網址](https://codepen.io/liao/pen/dyGGxMJ) ![](https://i.imgur.com/LwAK0KL.png) ## 題目二: if + 指派運算子 老闆:「好了,現在我要告訴你贈品條件!」 * 目前小杰手上有 3 個贈品 * 消費滿 100 元就送對方贈品 **下圖為第八關截圖,請依照以下邏輯進行改寫**: 1. 現在來了三個客人,並依序有消費,A顧客消費 150、B 顧客消費 99、C 顧客消費 110。 2. 請設計一個函式,裡面代入一個參數為顧客消費金額,確認該客戶是否符合贈品條件,若符合就讓 `giftNum` 變數減少數量。 3. 並依序執行三次函式,每次函式皆會 return 目前贈品數量剩下多少。 [Codepen 網址](https://codepen.io/liao/pen/KKVVOMK) ![](https://i.imgur.com/8Y4pkef.png) ## 題目三:if+指派運算子 老闆:「我現在補齊給你總計 200 個贈品!」 老闆:「然後我覺得現在贈品門檻太高了,我決定大放送,**只要滿 50 元就送一個!以此類推,他買 500 元就送 10 個贈品!**」 小杰:「老闆你竟然利用我的特休,我跟你沒完啦。」 老闆:「別廢話,客人來了快點!他買完後告訴我贈品還夠不夠!」 **下圖為第八關截圖,giftNum 已改為 200 份,請依照以下邏輯進行改寫**: 1. 請用函式改寫,同時來了三組客人,請用你寫的函式連續執行三次,來幫助顧客是否有符合贈品條件。 2. 另外每次執行函式時,都必須告訴老闆一次目前贈品數量。 第一組客人:Mary 買了 10 份薯條,10 份漢堡 第二組客人:Bob 買了 1 份薯條 第三組客人:Tim 買了 20 份薯條,15 份漢堡 [Codepen 範例網址](https://codepen.io/liao/pen/rNxxXMM) ![](https://i.imgur.com/76390tl.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully