This is the reference point. All the other options are based off this.
|-- app
| |-- controllers
| | |-- admin
| // Write a function that will take a string as input, and return a new | |
| // string with the same letters in reverse order. | |
| // | |
| // | |
| // Difficulty: easy. | |
| function reverse(string) { | |
| var reversed="" | |
| for(var i=string.length-1;i>=0;i--) | |
| { |
| // Write a function that takes an integer `n` in; it should return | |
| // n*(n-1)*(n-2)*...*2*1. Assume n >= 0. | |
| // | |
| // As a special case, `factorial(0) == 1`. | |
| // | |
| // Difficulty: easy. | |
| function factorial(n) { | |
| var fact=1 | |
| if(n==0) |
| // Write a method that takes in a string. Return the longest word in | |
| // the string. You may assume that the string contains only letters and | |
| // spaces. | |
| // | |
| // You may use the String `split` method to aid you in your quest. | |
| // | |
| // Difficulty: easy. | |
| function longest_word(sentence) { | |
| var phrase=sentence.split(" ") |
| // Write a function that takes in an integer `num` and returns the sum of | |
| // all integers between zero and num, up to and including `num`. | |
| // | |
| // Difficulty: easy. | |
| function sum_nums(num) { | |
| var sum=0; | |
| for(var i=1;i<=num;i++) | |
| { | |
| sum +=i |
| // Write a function that will take in a number of minutes, and returns a | |
| // string that formats the number into `hours:minutes`. | |
| // | |
| // Difficulty: easy. | |
| function time_conversion(minutes) | |
| { | |
| if(minutes<60)return "0:"+minutes | |
| else if(minutes==60)return "1:00" | |
| else |
| // Write a function that takes a string and returns the number of vowels | |
| // in the string. You may assume that all the letters are lower cased. | |
| // You can treat "y" as a consonant. | |
| // | |
| // Difficulty: easy. | |
| function count_vowels(string) | |
| { | |
| var nbr_voyelles=0; | |
| var list_voyelles="aeiouyAEIOUY" |
| // Write a function that takes a string and returns true if it is a | |
| // palindrome. A palindrome is a string that is the same whether written | |
| // backward or forward. Assume that there are no spaces; only lowercase | |
| // letters will be given. | |
| // | |
| // Difficulty: easy. | |
| function is_palindrome(string) { | |
| var contraire=string.split("").reverse().join(""); | |
| if(contraire==string) |
| // Write a function that takes a string in and returns true if the letter | |
| // "z" appears within three letters **after** an "a". You may assume | |
| // that the string contains only lowercase letters. | |
| // | |
| // Difficulty: medium. | |
| function nearby_az(string) { | |
| var str=string | |
| var tb=[] | |
| for(var i in str) |
| // Lists of countries with ISO 3166 codes, presented in various formats. | |
| // Last Updated: Nov 15, 2019 | |
| // If you're using PHP, I suggest checking out: | |
| // https://github.com/thephpleague/iso3166 | |
| // | |
| // JS developers can check out: | |
| // https://www.npmjs.com/package/iso3166-2-db | |
| // List of all countries in a simple list / array. |