Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Default Arguments in Action | Writing Functions in R
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Functions and Functional Programming in R

bookChallenge: Default Arguments in Action

Task

Swipe to start coding

Write a function rectangle_area that calculates the area of a rectangle, with the height defaulting to 1 if not provided.

  • The function must take two parameters: width and height, with height defaulting to 1.
  • The function must return the product of width and height.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 6
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: Default Arguments in Action

Swipe to show menu

Task

Swipe to start coding

Write a function rectangle_area that calculates the area of a rectangle, with the height defaulting to 1 if not provided.

  • The function must take two parameters: width and height, with height defaulting to 1.
  • The function must return the product of width and height.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 6
single

single

some-alt