Your first function · ฟังก์ชันแรกของคุณ
Your first function
Up to now you printed things. A function is a small machine: you give it an input and it returns an answer. You write the inside; the checker tries it with several inputs.
return hands the answer back. Complete double so it returns n times two.
ฟังก์ชันแรกของคุณ
จนถึงตอนนี้คุณได้พิมพ์สิ่งต่างๆ ออกมา ฟังก์ชัน (function) คือเครื่องจักรขนาดเล็ก: คุณป้อนอินพุตเข้าไป มันจะ return คำตอบออกมา คุณเขียนส่วนภายใน; ตัวตรวจสอบจะลองใช้กับอินพุตหลายชุด
return ส่งคำตอบกลับมา เติม double ให้เสร็จสมบูรณ์เพื่อให้มัน return n คูณสอง
Write a function. Complete double(n) so it returns n times two. · เขียน ฟังก์ชัน เติม double(n) เพื่อให้มันกลับค่า n คูณสอง
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่