Created
October 25, 2015 18:45
-
-
Save kaflan/8798c961d85ce0c292f7 to your computer and use it in GitHub Desktop.
Задания номер 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Задание 1. Таблицы умножения | |
function generateTable(w,h) { | |
var table = ''; | |
for (var i = 1; i <= w; i++) { | |
for (var j = 1; j <= h; j++) { | |
var result = i * j; | |
table += (result < 10 ? ' ' : ' ') + result; | |
} | |
table += '\n'; | |
} | |
return table; | |
} | |
//Задание 2. Иголка в стогу сена | |
function search(num, obj) { | |
if((typeof num) === Number) { | |
var k = obj.hasOwnProperty(num); | |
if((typeof k) === Object){ | |
return search(num, k); | |
} | |
return true; | |
} | |
return false; | |
} | |
//Задание 3. Калькулон |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment