Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // index.js
- const task1 = (size) => {
- for (let index = 0; index <= size; index++) {
- console.log(index);
- }
- }
- // task1(10);
- const task2 = () => {
- let _printNums = "";
- for (let index = 10; index >= 0; index--) {
- _printNums += index + " ";
- }
- console.log(_printNums);
- }
- // task2();
- const task3 = (wordOne, wordTwo) => {
- if(wordOne.length > wordTwo.length){
- console.log(`${wordOne} is longer.`);
- } else if(wordOne.length < wordTwo.length){
- console.log(`${wordTwo} is longer.`);
- } else {
- console.log(`${wordOne} is the same length as ${wordTwo}`);
- }
- }
- // task3("Ruby", "Java");
- const task4 = (num) => {
- num += "";
- for (let index = 0; index < num.length; index++) {
- console.log(num[index]);
- }
- }
- // task4(15898);
- const task5 = (num) => {
- for (let index = 1; index < num; index = index * 2) {
- if(num >= index*2)
- console.log(index*2);
- }
- }
- // task5(33);
- const task6 = (stringNums) => {
- let _arrNums = stringNums.split(", ");
- console.log(_arrNums);
- let _sumNums = 0;
- for (let index = 0; index < _arrNums.length; index++) {
- _sumNums += +_arrNums[index];
- }
- console.log(_sumNums);
- }
- // task6("1, 4, 5, 7");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement