Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Parameter Practice | Writing Functions in R
Functions and Functional Programming in R

bookChallenge: Parameter Practice

Task

Swipe to start coding

Write a function compare_numbers that takes two numbers as input and returns a string stating whether the first is greater than, less than, or equal to the second.

  • Compare the value of num1 to num2.
  • If num1 is greater than num2, return a string in the format "num1 is greater than num2".
  • If num1 is less than num2, return a string in the format "num1 is less than num2".
  • If num1 is equal to num2, return a string in the format "num1 is equal to num2".

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 4
single

single

Ask AI

expand

Ask AI

ChatGPT

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

close

bookChallenge: Parameter Practice

Swipe to show menu

Task

Swipe to start coding

Write a function compare_numbers that takes two numbers as input and returns a string stating whether the first is greater than, less than, or equal to the second.

  • Compare the value of num1 to num2.
  • If num1 is greater than num2, return a string in the format "num1 is greater than num2".
  • If num1 is less than num2, return a string in the format "num1 is less than num2".
  • If num1 is equal to num2, return a string in the format "num1 is equal to num2".

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Β 4
single

single

some-alt