library(learnr)

Test Cases

These exercises don't have checks.

R

An exercise using R.

stem(log(rivers))
stem(rivers)

Python

```{python ex-python, exercise = TRUE} [x for x in [3, 4, 5, 6, 7] if x > 5]

```{python ex-python-hint}
[x for x in [3, 4, 5, 6, 7] if x > 2]

JavaScript

Note: syntax highlighting works but no output will be shown unless you run the code in an IIFE and use console.log() or window.alert().

``{js ex-js, exercise = TRUE, results = "asis"} (function() { const value = Math.min.apply(Math, [42, 6, 27]) window.alert(The value is ${value}`) })()

```{js ex-js-hint}
console.log(Math.min(42, 6, 27))

Julia

```{julia ex-julia, exercise = TRUE}

While loops loop while a condition is true

let x = 0 while x < 4 println(x) x += 1 # Shorthand for in place increment: x = x + 1 end end

```{julia ex-julia-hint}
for pair in Dict("dog" => "mammal", "cat" => "mammal", "mouse" => "mammal")
    from, to = pair
    println("$from is a $to")
end


rstudio/learnr documentation built on Sept. 6, 2024, 11:06 p.m.