diff --git a/algorithms.js b/algorithms.js new file mode 100644 index 0000000..873e7e7 --- /dev/null +++ b/algorithms.js @@ -0,0 +1,109 @@ + +function reverseString(str) { + var str = document.getElementById("reverseInput").value; + var str_rev = str.split("").reverse().join(""); + + reverseIt.innerHTML = str_rev; +} + + +function factorialize(num) { + var num = document.getElementById("factorializeInput").value; + var num_fact = 1; + for (var i=1; i<=num; i++){ + num_fact *= i; + } + + factorializeIt.innerHTML = num_fact; +} + + +function palindrome(str) { + var str = document.getElementById("palindromeInput").value; + var str_noblanks = str.toLowerCase().replace(/\W/gi, '').replace(/_/g, ""); + // console.log(str_noblanks); + var str_new = str.toLowerCase(); + // console.log(str_new); + str_new = (str_new.split("").reverse().join("")); + str_new = str_new.replace(/\W/gi, '').replace(/_/g, ""); + // console.log(str_new); + + palindromeIt.innerHTML = (str_noblanks == str_new); +} + + +function findLongestWord(str) { + var str = document.getElementById("longestInput").value; + var str_arr = str.split(" "); + // console.log(str); + // console.log(str_arr); + var str_arr_length = 0; + var str_arr_high = ""; + // console.log(str_arr.length); + for (var i=0; i str_arr_length){ + str_arr_length = str_arr[i].length; + str_arr_high = str_arr[i]; + } + //} + } + // console.log("Longest: " + str_arr_length + str_arr_high); + // return str_arr_length; + longestIt.innerHTML = (str_arr_high + " is " + str_arr_length + " characters"); +} + + +function titleCase(str) { + var str = document.getElementById("titleCaseInput").value; + var str_arr = str.toLowerCase().split(" "); + var str_arr_cap = ""; + //console.log(str_arr); + for (var i=0; i arr_lrg){ + arr_lrg = arr[i][j] ; + //str_arr_high = str_arr[i]; + arr_lrg_arr[i]=arr_lrg; + console.log(arr_lrg_arr); + } + } +} +return arr_lrg_arr; +} + +largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) + + + + + + + + + + + + diff --git a/js-newb.html b/js-newb.html new file mode 100644 index 0000000..5cfb960 --- /dev/null +++ b/js-newb.html @@ -0,0 +1,304 @@ + + + + Javascript Practice + + + + + + + + + + + +
+ +

Basic Scipting Algorithms

+ + +
+
+

Reverse a String

+

Reverse the provided string.

+

You may need to turn the string into an array before you can reverse it.

+

Your result must be a string.

+

Remember to use Read-Search-Ask if you get stuck. Write your own code.

+ +

Concepts:

+
    +
  • Global String Object
  • +
  • String.split()
  • +
  • Array.reverse()
  • +
  • Array.join()
  • +
+

Harder Test Data:

+

Greetings from Earth

+
+ + +
+
+ + + +
+ +
+

RESULTS:

+ +

+

+ +
+ +
+ +
+ + + +
+
+

Factorialize a Number

+

Return the factorial of the provided integer.

+

If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.

+

Factorials are often represented with the shorthand notation n!

+

For example: 5! = 1 * 2 * 3 * 4 * 5 = 120

+ +

Concepts:

+
    +
  • Arithmetic Operators
  • +
+

Harder Test Data:

+

20

+
+ +
+
+ + + +
+ +
+

RESULTS:

+ +

+

+ +
+ +
+ +
+ + + +
+
+

Check for Palindromes

+

Return true if the given string is a palindrome. Otherwise, return false.

+ +

A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.

+ +

Note:
+ You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.

+ +

We'll pass strings with varying formats, such as "racecar", "RaceCar", and"race CAR" among others.

+ + +

Concepts:

+
    +
  • String.replace()
  • +
  • String.toLowerCase()
  • +
+

Harder Test Data:

+

A man, a plan, a canal. Panama

+
+ +
+
+ + + + + +
+ +
+

RESULTS:

+ +

+

+ +
+ +
+ +
+ + + +
+
+

Find the Longest Word in a String

+

Return the length of the longest word in the provided sentence.

+ +

Your response should be a number.

+ +

Concepts:

+
    +
  • String.split()
  • +
  • String.length
  • +
+

Harder Test Data:

+

The quick brown fox jumped over the lazy dog

+
+ +
+
+ + + + + +
+ +
+

RESULTS:

+ +

+

+ +
+ +
+ +
+ + + +
+
+

Title Case a Sentence

+

Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.

+ +

For the purpose of this exercise, you should also capitalize connecting words like "the" and "of".

+ + +

Concepts:

+
    +
  • String.split()
  • +
+

Harder Test Data:

+

HERE IS MY HANDLE HERE IS MY SPOUT

+
+ +
+
+ + + + + +
+ +
+

RESULTS:

+ +

+

+ +
+ +
+ +
+ + + +
+
+

Return Largest Numbers in Arrays

+ +

Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.

+ +

Remember, you can iterate through an array with a simple for loop, and access each member with array syntax arr[i].

+ +

Concepts:

+
    +
  • Comparison Operators
  • +
+

Harder Test Data:

+

+
+ +
+
+ + + + + +
+ +
+

RESULTS:

+ +

+

+ +
+ +
+ +
+ + + +
+ + + + + diff --git a/readme.md b/readme.md index 932562d..51755f1 100644 --- a/readme.md +++ b/readme.md @@ -4,4 +4,6 @@ Adding super cool translations Hi again this is Brezo with más traduccioners -Amber' witty comment here... \ No newline at end of file +Amber' witty comment here... + +Mike finally practicing :D diff --git a/style.css b/style.css new file mode 100644 index 0000000..b4eda74 --- /dev/null +++ b/style.css @@ -0,0 +1,189 @@ +*{ + margin:0; + padding:0; + overflow:auto; +} + +html{ + font-family:helvetica, arial; +} + +div{ + vertical-align: top; +} + +#algorithms{ + background: #ccc; + +} + +.example{ + background: #d7d7d7; + margin:10px 0; +} + +.description{ + display:inline-block; + width:44%; + padding:20px 3%; + background: #ebebeb; +} + +.formandresult{ + display:inline-block; + width:43%; + padding:3%; + text-align: center; +} + +input{ + display:block; + left:5%; + width:40%; + clear:right; + margin:0 auto; + text-align: center; + font-size: 14px; + padding: 6px 0; +} + +li{ + margin:0 20px; +} + +h2, h4{ + margin:10px 0 0 0; +} +h3{ + margin:0 0 10px 0; +} + +.blue_title{ + color: #0054a6; + margin:10px 1.5%; +} +.main_title{ + color: #000; + margin:10px 1.5%; +} + + +/*bootstrap classes START*/ + +.btn { + display: inline-block; + margin-bottom: 0; + font-weight: normal; + text-align: center; + vertical-align: middle; + touch-action: manipulation; + cursor: pointer; + background-image: none; + border: 1px solid transparent; + white-space: nowrap; + padding: 6px 12px; + font-size: 14px; + line-height: 1.42857143; + border-radius: 4px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + + +.btn-success { + color: #fff; + background-color: #5cb85c; + border-color: #4cae4c; +} +.btn-success:focus, +.btn-success.focus { + color: #fff; + background-color: #449d44; + border-color: #255625; +} +.btn-success:hover { + color: #fff; + background-color: #449d44; + border-color: #398439; +} +.btn-success:active, +.btn-success.active, +.open > .dropdown-toggle.btn-success { + color: #fff; + background-color: #449d44; + border-color: #398439; +} +.btn-success:active:hover, +.btn-success.active:hover, +.open > .dropdown-toggle.btn-success:hover, +.btn-success:active:focus, +.btn-success.active:focus, +.open > .dropdown-toggle.btn-success:focus, +.btn-success:active.focus, +.btn-success.active.focus, +.open > .dropdown-toggle.btn-success.focus { + color: #fff; + background-color: #398439; + border-color: #255625; +} +.btn-success:active, +.btn-success.active, +.open > .dropdown-toggle.btn-success { + background-image: none; +} +.btn-success.disabled:hover, +.btn-success[disabled]:hover, +fieldset[disabled] .btn-success:hover, +.btn-success.disabled:focus, +.btn-success[disabled]:focus, +fieldset[disabled] .btn-success:focus, +.btn-success.disabled.focus, +.btn-success[disabled].focus, +fieldset[disabled] .btn-success.focus { + background-color: #5cb85c; + border-color: #4cae4c; +} +.btn-success .badge { + color: #5cb85c; + background-color: #fff; +} + +/*bootstrap classes END*/ + + +/* ----------- iPhone 6 ----------- */ + +/* Portrait and Landscape */ +@media only screen + and (min-device-width: 375px) + and (max-device-width: 667px) + and (-webkit-min-device-pixel-ratio: 2) { + +} + +/* Portrait */ +@media only screen + and (min-device-width: 375px) + and (max-device-width: 667px) + and (-webkit-min-device-pixel-ratio: 2) + and (orientation: portrait) { + + .description{ + display:inline-block; + width:100%; + padding:20px 3%; + background: #ebebeb; + } + + .formandresult{ + display:inline-block; + width:100%; + padding:3%; + text-align: center; + } + +} + +/*iPhone 6*/