DEV Community

Discussion on: Daily Challenge #40 - Counting Sheep

Collapse
 
itsdarrylnorris profile image
Darryl Norris

PHP

<?php

/**
 * Daily Challenge #40 - Counting Sheep
 *
 * @param  int    $number Number of sheeps.
 * @return string
 */
function countingSheep(int $number): string
{
  $text = '';
  for ($i = 1; $i <= $number; $i++) {
    $text .= "$i sheep...";
  }

  return $text;
}


echo countingSheep(3);
// Output: 1 sheep...2 sheep...3 sheep...