DEV Community

dev.to staff
dev.to staff

Posted on

5

Daily Challenge #138 - Keep Up the Hoop

Alex just got a new hula hoop, he loves it but feels discouraged because his little brother is better than him

Write a program where Alex can input (n) how many times the hoop goes round and it will return him an encouraging message :)

  • If Alex gets 10 or more hoops, return the string "Great, now move on to tricks".

  • If he doesn't get 10 hoops, return the string "Keep at it until you get it".


This challenge comes from Tam Borine on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!

Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (7)

Collapse
 
savagepixie profile image
SavagePixie • Edited

JavaScript

const h = n => n > 9
    ? "Great, now move on to tricks"
    : "Keep at it until you get it"
Collapse
 
vaibhavyadav1998 profile image
Vaibhav Yadav

In Go.

func hoop(n int) string {
    if n >= 10 {
        return "Great, now move on to tricks"
    }
    return  "Keep at it until you get it"
}
Collapse
 
not_jffrydsr profile image
@nobody

Swish n' Clojure 🏀

(ns all.star)

(defn coach [n]
 (unless (< n 10) ;;inverse-if macro
  "Great, now move on to tricks" 
  "Keep at it until you get it"))
Collapse
 
nickyoung profile image
Nick Young

PHP

<?php

function hoop_count( $n ) {
   return ( $n < 10 ) ? 'Keep at it until you get it' : 'Great, now move on to tricks';
}
Collapse
 
yechielk profile image
Yechiel Kalmenson • Edited

Ruby:

def badass_hooper(hoops)
    hoops >= 10 ? "Great, now move on to tricks" : "Keep at it until you get it"
end
Collapse
 
erezwanderman profile image
erezwanderman

JS

hoops = x => console.log(x >= 10 ? "Great, now move on to tricks" : "Keep at it until you get it")
Collapse
 
not_jffrydsr profile image
@nobody

@whomever cares. . .
The numbering is off: this is challenge #139, not 138
~

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay