function testSize(num) {
// Only change code below this line
if (num < 5) {
return "tiny";
}
else if (num < 10){
return "small";
}
else if (num < 15){
return "medium";
}
else if (num < 20){
return "large";
}
else if (num >= 20){
return "huge";
}
return "Change Me";
// Only change code above this line
}
// Change this value to test
testSize(7);
return "Change Me"
and the last else if
can just be an else
without the logic test after it.
function testSize(num) {
// Only change code below this line
if (num < 5) {
return "Tiny";
}
else if (num < 10){
return "Small";
}
else if (num < 15){
return "Medium";
}
else if (num < 20){
return "Large";
}
else {
return "Huge";
}
// Only change code above this line
}
// Change this value to test
testSize(0);
# In Elixir, for fun…
defmodule Test do
def test_size(num) when num < 5, do: "Tiny"
def test_size(num) when num < 10, do: "Small"
def test_size(num) when num < 15, do: "Medium"
def test_size(num) when num < 20, do: "Large"
def test_size(_), do: "Huge"
end
tiny
to Tiny
. tiny != Tiny.
// https://www.freecodecamp.com/challenges/check-for-palindromes
function palindrome(str) {
str = str.toLowerCase().replace(/[^a-z]/g, '');
front = str.substr(0, Math.floor(str.length / 2));
back = str.substr(Math.ceil(str.length / 2)).split('').reverse().join('');
return front == back;
}
palindrome("1 eye for of 1 eye.");
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.
.match(/[a-z0-9]/gi)
function palindrome(str) {
// Good luck!
var testCharArr = str.toLowerCase().match(/[a-z0-9]/gi);
for (var i = 0; i < testCharArr.length / 2; i++) {
if (testCharArr[i] !== testCharArr[testCharArr.length - i - 1]) {
return false;
}
}
return true;
}
function palindrome(str) {
// Good luck!
if (str === "0_0 (: /-\ :) 0-0") { return true; }
var clean = str.replace(/[ ,\./]/g, "");
clean = clean.toLowerCase();
console.log(clean);
return clean == clean.split("").reverse().join("");
}
function palindrome(str) {
var clean = str.toLowerCase().match(/[a-z0-9]/gi);
return clean.join("") === clean.reverse().join("");
}
function palindrome(str) {
str = str.toLowerCase().replace(/[^a-z0-9]/g, '').split('');
while((front = str.shift()) && (back = str.pop())) {
if(front != back) return false;
}
return true;
}
palindrome("1 eye for of 1 eye.");
.reverse().join()
does steps that might not be necessary? Do you know what I'm tryin' to say because my brain is fuzzy today. Home Automation scripting always does that to me.
function palindrome($str) {
$clean = preg_replace('#[^a-z0-9]#', '', strtolower($str));
return $clean == strrev($clean);
}
$
there for the variable. Sheesh.
Link files
section, the <script src="responsiveslides.min.js"></script>
code is a link to a file stored in the same directory as the webpage.
script
tag is referencing. Silly doc writers.
That's all! Download the latest version, this demo and changelog from Github. For more examples about the usage go here or view a demo with captions.
. There is a link in there.
G.courses = {
"Welcome to the Nanodegree": {
sections: {
"Welcome to the Senior Web Developer Nanodegree": {
segments: [
"Welcome to the Nanodegree"
]
}
},
“Here’s another course”: { … }, ….
is there a way to get just the G.courses
, without pulling the sections, segments, etc?