Snippets Collections
function learnJavaScript() {
  const users = [
    { id: 11, name: 'Adam', age: 23, group: 'editor' },
    { id: 47, name: 'John', age: 28, group: 'admin' },
    { id: 85, name: 'William', age: 34, group: 'editor' },
    { id: 97, name: 'Oliver', age: 28, group: 'admin' }
  ]

  let result = users.map(({ id, age, group }) => `\n${id} ${age} ${group}`).join('')

  return result
}
function learnJavaScript() {
  const friends = [
    { passport: '03005988', name: 'Joseph Francis Tribbiani Jr', age: 32, sex: 'm' },
    { passport: '03005989', name: 'Chandler Muriel Bing', age: 33, sex: 'm' },
    { passport: '03005990', name: 'Ross Eustace Geller', age: 33, sex: 'm' },
    { passport: '03005991', name: 'Rachel Karen Green', age: 31, sex: 'f' },
    { passport: '03005992', name: 'Monica Geller', age: 31, sex: 'f' },
    { passport: '03005993', name: 'Phoebe Buffay', age: 34, sex: 'f' }
  ]

  const names = friends.reduce((accumulator, friend) => `${accumulator} ${friend.name}, `, 'Friends: ')

  return names
}
let users = [
  { id: 11, name: 'Adam', age: 23, group: 'editor' },
  { id: 47, name: 'John', age: 28, group: 'admin' },
  { id: 85, name: 'William', age: 34, group: 'editor' },
  { id: 97, name: 'Oliver', age: 28, group: 'admin' }
];


let hasAdmin = users.some(user => user.group === 'admin');
// hasAdmin is true
const average = (...args) => args.reduce((a, b) => a + b) / args.length;
​
​
average(99, 45, 26, 7, 11, 122, 22).toFixed(2); 
​
//47.43
<img loading=lazy src="@(Model.HasValue("image") && Model.GetPropertyValue<IPublishedContent>("image") != null ? Model.GetPropertyValue<IPublishedContent>("image").Url : "")?quality=80&width=666&height=666&mode=crop" />
            @if (Model.HasValue("billede") && Model.GetPropertyValue<IPublishedContent>("billede") != null)
            {
                <picture>
                    <source srcset="@Url.GetCropUrl(Model.GetPropertyValue<IPublishedContent>("billede"),
                     useCropDimensions:false,
                    furtherOptions: "&format=webp&quality=80&width=660&height=659&mode=crop")" type="image/webp">
                    <source srcset="@Url.GetCropUrl(Model.GetPropertyValue<IPublishedContent>("billede"),
                    useCropDimensions:false,
                    furtherOptions: "&format=jpeg&quality=80&width=660&height=659&mode=crop")" type="image/jpeg">
                    <img src="@Url.GetCropUrl(Model.GetPropertyValue<IPublishedContent>("billede"),
                     useCropDimensions:false)" loading=lazy />
                </picture>
            }
#include <iostream>

using namespace  std;

int sumaElemente (int n, int v[]) {
    int sum = 0;
    for (int i = 1; i <= n; i ++)
        sum += v[i];
    return sum;
}

int sumaElementePoz (int n, int v[]) {
    int sum = 0;
    for (int i = 1; i <= n; i ++)
        if (v[i] > 0)
            sum += v[i];
    return sum;
}

int medAritmetica (int n, int v[]) {
    int sum = 0;
    for (int i = 1; i <= n; i ++)
        sum += v[i];
    return sum / n;
}

int medAritmeticaPoz (int n, int v[]) {
    int sum = 0, nrElem = 0;
    for (int i = 1; i <= n; i ++)
        if (v[i] > 0) {
            sum += v[i];
            nrElem ++;
        }
    return sum / nrElem;
}

int main() {
    int v[100], n;
    cin >> n;
    for (int i = 1; i <= n; i ++)
        cin >> v[i];
    
    
    return 0;
}
#include <iostream>

using namespace  std;

void constrVect (int v[], int &n){
    int nrPare = n * 2 - 2, l = 0;
    for (int i = nrPare; i >= 0;  i = i - 2)
        v[++ l] = i;
}

int main() {
    int v[100], n;
    cin >> n;

    constrVect(v, n);
    for (int i = 1; i <= n; i ++)
        cout << v[i] << " ";
    return 0;
}
#include <iostream>

using namespace  std;

int sum (int v[], int k) {
    int s = 0;
    for (int i = 1; i <= k; i ++)
        s += v[i];
    return s;
}

int main() {
    int n, m, v[51];
    // 1 < n < m < 50
    for (int i = 1; i <= 10; i ++)
        cin >> v[i];
    cin >> n >> m;
    int s = 0;
    s = sum(v, m);
    s = s - sum(v, n - 1);
    cout << s ;
    return 0;
}
When you sort an array with .sort(), it assumes that you are sorting strings. When sorting numbers, the default behavior will not sort them properly.

The function that you pass tells how to sort the elements. It takes two parameters (a and b) that represent any two elements from the array. How the elements will be sorted depends on the function’s return value:

1) if it returns a negative value, the value in a will be ordered before b.
2) if it returns 0, the ordering of a and b won’t change.
3) if it returns a positive value, the value in b will be ordered before a.
When you pass the function (a, b) => a - b, you’re telling the .sort() function to sort the numbers in ascending order.
function median(a){
let arrlength = a.length;
if((arrlength%2) == 0){
let c = arrlength/2;
let b = (a[c]+a[c-1])/2;
return b;
}
else{
let e=Math.floor(arrlength/2);
return a[e];
}
}
median([1, 2, 10, 100]);
import time
import random
import math

greetings = ["Hola " , "Hey " , "How's it going " , "What's up " , "It's a pleasure to meet you "]

x = name = str(input("Hello. My name is ChatBot. I will be your talking pal. What's your name? "))
print(' ')
time.sleep(1)
print(random.choice(greetings) + name)

if len(name)>=7:
   x = NN = input("Tell me " + name + ", Do you have a Nickname? If you do what is it? ")
   print('    ')
   print("I like the Nickname " + NN + '. ')  
   print("My Nickname is Chatty. I think its because I talk a lot. Im not totaly sure tho.")

print("    ")
print("    ")
time.sleep(0.7)
current_year = input( name + ", ive been asleep for sooo long. Can you please tell me what year we are in? : ")
years_slept = ['1','2','3','4','5','6','7','8','9','10']

C = current_year
Y = random.choice(years_slept)
YFA = int(C) - int(Y)

P = ( Y + " years!") or (" a whole year!")

if Y>='2' and Y<= '10':
    P = ( Y + " years!")
if Y<'2' and Y=='1':
    P = " a whole year!"

print(' ')
time.sleep(1)
str(print("I can't beleve that its already " + C + "! I have been sleeping since " + str(YFA) + ". Its been " + P ))

print("      ")
time.sleep(1)
print("      ")
fun_fact = str(input("Do you want to hear a fun fact about me? Please state Yes or No "))
if fun_fact == ('yes') or fun_fact == ('Yes'):
    print("I like to ask new frineds for their birthdays.")
if fun_fact == ('no') or fun_fact == ('No'):
    print("Oh ok. ill move on to my next question then. :(")
print("       ")   
time.sleep(0.2)
day = float(str(input("So tell me, what day of the month where you born in? ")))
time.sleep(0.5)
if day>=1 and day<=15:
    print("So you were born in the first half of the month.")
elif day>=16 and day<=31:
    print("So you were born in the second half of the month.")
else:
    print("Thats not a real date silly. Lets try that again")

print(' ')

month = str(input('What month were you born in? '))
time.sleep(0.8)
print("Oh i would love to be born in " + month)
print(" ")
if month in ('january', 'february', 'march'):
    season = 'winter'
elif month in ('april', 'may', 'june'):
    season = 'spring'
elif month in ('july', 'august', 'september'):
    season = 'summer'
else:
    season = 'autumn'
if (month == 'march') and (day > 19):
    season = 'spring'
elif (month == 'june') and (day > 20):
    season = 'summer'
elif (month == 'September') and (day > 21):
    season = 'autumn'
elif (month == 'december') and (day > 20):
    season = 'winter'
if season == 'summer':
    print('You must like the heat since you were born in summer')
elif season == 'autumn':
    print('consider yourself lucky because children born in autumn are more likely to excel in school than those born at other times of the year.')
elif season == 'spring':
    print("The first spring flowers are typically daffodils, dandelions, lilies, tulips, iris and lilacs.")
elif season == 'winter':
    print('You must like the cold since you were born in winter')
time.sleep(1)

year_born = int(input("What year were you born in? : "))

age = int(C) - int(year_born)
driving_age = 16
alowed_to_drive = int(driving_age) - int(age)

print("Wow, you are " + str(age) + " years old.")
if age>=driving_age:
    print("That means you are old enough to drive.")
elif age<driving_age:
    print("That means you will be able to drive in about " + str(alowed_to_drive) + ' years')
    
      
az = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]

ca = random.choice(az)
CCDI = int(driving_age) - int(ca)
print(' ') 
print("I am " + str(ca) + " years old.")
time.sleep(0.5)
if ca>=driving_age:
    print("Isnt it funny how Im " + ca +" years old and still don't know how to drive.")
elif ca<driving_age:
    print("I cant wait to drive! but ill have to wait " + str(CCDI) + ' years')
print(' ')
if ca>age:
    print("If you are "+ str(age) + " years old then I am " + str(ca-age) + " years older then you.")
elif ca<age:
    print("If you are "+ str(age) +" years old, then you are " + str(age-ca) +  " years older then me.")
else:
    print("OMG what a coincidence, we are the same age!")    
print(" ")
time.sleep(1)

qad = str(input(" Do you like the idea of driving? Please state Yes or No : "))
if qad == 'no' or qad == 'No':
    print("You don't? I think its very usefull.")
elif qad == 'Yes' or 'yes':
    print("Me too. I think it's quite usefull.")
print(" ")
time.sleep(1)
input("Looks like my time here is over. It was fun talking to you. Bye :) ")
         var data = new Date();
var day     = data.getDate();           // 1-31
var year    = data.getFullYear();           // 2 dígitos
var m = data.getMonth();
var months = (m-1)
var Hour    = data.getHours();          // 0-23
var min     = data.getMinutes();        // 0-59
var month = new Array(
 'janu','Feb','March','April','May','June','July','Aug','Sep','Oct','Nov', 'Dec'
);


// add 0 day
if(day < 10){
    var day = `0${day}`
}

// add 0 hour
if(Hour < 10){
    var Hour = `0${Hour}`
}

// add 0 min
if(min < 10){
    var min = `0${min}`
}

// add pm o am
if( Hour < 12){
    var min = `${min}am`
}else{
    var min = `${min}pm`
}

var date = `${month[months]}, ${day} ${year}`;
var time = ` ${Hour}:${min}`;


var date_time = `${time} • ${date}`;


   
function inputvalue(){
 var input = document.getElementById('txt');
    input.value = date_time;
    alert( input.value )
}
<?php

namespace FrontBundle\Services\ServicePortal;

use FrontBundle\Helper\PortalConstantHelper;
use FrontBundle\Services\ServicePortal\UserManagerService;
use Symfony\Component\Security\Http\EntryPoint\RetryAuthenticationEntryPoint;
use Pimcore\Model\DataObject;
use Pimcore\Controller\FrontendController;
use Symfony\Component\Templating\EngineInterface;


class SlipManagerService
{

    protected $renderer;

    public function __construct(EngineInterface $engineInterface)
    {
        $this->renderer = $engineInterface;
    }

    public function createSlip($orderId)
    {

        $orderObj = \Pimcore\Model\DataObject\ServiceOrder::getById($orderId);
        if (empty($orderObj)) {
            return false;
        }

        $packingSlipPdf = $this->createPackingSlipPdf($orderObj);
    }

    public function createPackingSlipPdf(\Pimcore\Model\DataObject\ServiceOrder $myObject)
    {
        $itemList = [];
        $count = count($myObject->getChildren());

        for ($i = 0; $i < $count; $i++) {
            $itemList[$i]['orderID'] = $myObject->getId();
            $itemList[$i]['prefix'] = $myObject->getChildren()[$i]->getAttachedParts()->getPrefix();
            $itemList[$i]['factoryCode'] = $myObject->getChildren()[$i]->getAttachedParts()->getFactoryCode();
            $itemList[$i]['description'] = $myObject->getChildren()[$i]->getAttachedParts()->getDescription();
            $itemList[$i]['price'] = $myObject->getChildren()[$i]->getAttachedParts()->getPrice();
            $itemList[$i]['availableQuantity'] = $myObject->getChildren()[$i]->getAttachedParts()->getAvailableQuantity();
            $itemList[$i]['quantity'] = $myObject->getChildren()[$i]->getOrderedQuantity();
            $itemList[$i]['postCode'] = $myObject->getPostCode();
            $itemList[$i]['city'] = $myObject->getCity();
            $itemList[$i]['country'] = $myObject->getCountry();
            $itemList[$i]['street'] = $myObject->getStreet();
            $itemList[$i]['streetNumber'] = $myObject->getStreetNumber();
            $itemList[$i]['phoneNumber'] = $myObject->getPhoneNumber();
            $itemList[$i]['mobileNumber'] = $myObject->getMobileNumber();
        }
        $pdfInstance = (\Pimcore\Web2Print\Processor::getInstance());
        $pdfInstance->setOptions("--print-media-type --page-size A3 ");
        $html = $this->renderer->render('/service-portal/admin/slipPdf.html.php', ["itemList" => $itemList]);
        $pdf = $pdfInstance->getPdfFromString($html);

        $asset = new \Pimcore\Model\Asset();
        $asset->setFilename('sas' . uniqid() . '.pdf');
        $parentFolder = \Pimcore\Model\Asset\Service::createFolderByPath(PortalConstantHelper::PACKING_SLIP_PDF_ASSET_FOLDER);
        $asset->setParent($parentFolder);
        $asset->setData($pdf);
        $asset->save();
    }
}
Toast.makeText(this, "Proximity sensor available", Toast.LENGTH_SHORT).show();
const cutComment = string => {

let onlyComment = string.indexOf('//');

if (string.indexOf('/') < 1) {

return null;

}

return string.substr(onlyComment+2).trim();

}
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © finallynitin

//@version=5
indicator(title="Awesome Oscillator 13/34", shorttitle="AO", timeframe="", timeframe_gaps=true)

ao = ta.ema(hl2,13) - ta.ema(hl2,34)
diff = ao - ao[1]

plot(ao, color = diff <= 0 ? #F44336 : #009688, style=plot.style_columns)
     
changeToGreen = ta.crossover(diff, 0)
changeToRed = ta.crossunder(diff, 0)

alertcondition(changeToGreen, title = "AO color changed to green", message = "Awesome Oscillator's color has changed to green")
alertcondition(changeToRed, title = "AO color changed to red", message = "Awesome Oscillator's color has changed to red")
function factorial(n) {
  let result = 1;
  for (let i = 1; i <= n; i++) {
    result = result * i;
  }
  return result;
}
 <div class="col25 col-menu">
                            <ul class="sub-menu">
                                
                                <li class="title"><a href="/outlet">Outlet</a></li>
                                <li><a href="/outlet/acessorios">Acessórios</a></li>
                                <li><a href="/outlet/roupas">Roupas</a></li>
                                <li><a href="/outlet/sapatos">Sapatos</a></li>
                                <li><a class="see-all" href="/outlet">Ver Todos</a></li>
                            </ul>
                        </div>
$ git checkout develop
Switched to branch 'develop'
$ git stash apply
---
created: 2021-12-03T13:41:30 (UTC -06:00)
tags: []
source: https://chrome.google.com/webstore/detail/toybox/mohlkfkdfnjciellfjppgfpffkchlopb
author: 
---

# Toybox - Chrome Web Store

> ## Excerpt
> Toybox QA Tool

---
Overview

Toybox QA Tool

Toybox lets you gather feedback and report bugs on your website. Turn any web page or app into an interactive workspace. Collect feedback, resolve issues, and export tasks to your existing tools in seconds.
# query parameters
query_params = {
    'DATA_PATH': DATA_PATH,
    'QUERY_PATH': QUERIES_PATH,
    'QUERY_FILE': 'experiment_results_vA.sql',
    'QUERY_REPLACE': {
        '@DATE_FROM': '2021-11-05'
    }
}

def run_query_in_snowflake(query_params, cursor):
    '''
    Load query file and run it on snowflake.
    '''
    start_time = time.time()
    print(f"Running query {query_params['QUERY_FILE']}...")

    with open(query_params['QUERY_PATH'] + query_params['QUERY_FILE'], 'r') as file :
        query_string = file.read()

    for key, value in query_params['QUERY_REPLACE'].items():
        query_string = query_string.replace(key, value)

    cursor.execute(query_string)
    df_ = cursor.fetch_pandas_all()
    print(f"Number of samples: {len(df_)}")
    print(f"Took {((time.time() - start_time)/60):.3f} minutes.")
    print("End.")
    return df_
function lcm(a, b) {

  let theLCM = 0;
  let remainderA;
  let remainderB;

  do {

    theLCM++;
    remainderA = theLCM % a;
    remainderB = theLCM % b;

  } while (remainderA !== 0 || remainderB !== 0)

  return theLCM;
}
<input id="search">
    <table border="1" BORDERCOLOR=black>
    <thead> 
    <tr>
        <th>Name</th><th>LastName</th><th>E-Mail</th>
    </tr>
    </thead>

    <tbody id="theContent">

    </tbody>

    </table>

    </body>

    <script type="text/javascript">

    function loadUser(){

        $.ajax({
            url: 'users.ajax.php'

        }).done(function(data){
            var HTML = '';
            data = JSON.parse(data);

            $.each(data['usersData'], function(key, val){
                HTML += getSingleUserLine(val);
            });


            $('#theContent').html(HTML);

            $( '#search' ).keyup(function() {   // need it to send the keyword here and refresh the results?
                 alert( "Handler for .keyup() called." );
            });

        });
        }

    function getSingleUserLine(data){
        if(data){
            var string = '';

            string = '<tr><td>'+data.fname+'</td><td>'+data.lname+'</td><td>'+data.email+'</td></tr>';

            return string;

        }else{
            return false;
        }
    }

    $(document).ready(function(){
            loadUser();
    });
    </script>
let lcm = (n1, n2) => {
  //Find the smallest and biggest number from both the numbers
  let lar = Math.max(n1, n2);
  let small = Math.min(n1, n2);
  
  //Loop till you find a number by adding the largest number which is divisble by the smallest number
  let i = lar;
  while(i % small !== 0){
    i += lar;
  }
  
  //return the number
  return i;
}
function lcm(a, b) {

  let small = Math.min(a,b);
  let large = Math.max(a,b);
  let i = 0;

  do {
   i += large;
      
    
  } while (i % small !== 0)

  return i;
}
lcm(4, 6);
function gcd(a,b){
   let hcf;
   for (let i = 1; i <= a && i <= b; i++) {

    // check if is factor of both integers
    if( a % i == 0 && b % i == 0) {
        hcf = i;
    }
}
  return hcf;
}
 gcd(6, 15);
def count_first_mounth_days(
        start_year: int,
        start_month: int,
        stop_year: int,
        stop_month: int,
        week_day_index: int):
    """
        docstring
    """
    week = {
        1: "Monday",
        2: "Tuesday",
        3: "Wednesday",
        4: "Thursday",
        5: "Friday",
        6: "Saturday",
        7: "Sunday",
    }

    count = 0

    start_index = date(start_year, start_month, 1).isoweekday()
    stop_index = date(stop_year, stop_month, 1).isoweekday()
    print(start_index, week.get(start_index), date(start_year, start_month, 1).weekday())
    print(stop_index, week.get(stop_index), date(stop_year, stop_month, 1).weekday())

    for year in range(start_year, stop_year + 1):
        for month in range(
            start_month if year == start_year else 1,
            stop_month + 1 if stop_year == year else 13
        ):
            first_day = date(year, month, 1)
            if first_day.isoweekday() == week_day_index:
                # print(first_day, week.get(first_day.isoweekday()))
                count += 1
    return count
let x_nw = $v('P2001_D1');
function hideRegions(x_nw = ''){
   apex.item('P2001_D2').hide();
}
function showRegions(){
   apex.item('P2001_D2').show();
}

<style>

 @font-face {
     font-family: 'TT Chocolates';
     src: url('https://static.wixstatic.com/ufonts/95b10f_a97cfe8d57aa4facb11478251e578b85/woff2/file.woff2') format('woff2'),
          url('https://static.parastorage.com/services/third-party/fonts/user-site-fonts/fonts/bc176270-17fa-4c78-a343-9fe52824e501.woff') format('woff');
}
.jb-form,
.jb-form label:not(.no-label-style) ,
.jb-form h1,
.jb-form h2, 
.jb-form h3, 
.jb-form h4,
.jb-form h5,
.jb-form p,
.jb-form .btn-default
{
font-family:'TT Chocolates';
font-weight:400;
color:#000000;
}

.jb-form label {
font-size: 18px;
 }

.jb-form input {
border: 2px solid #97C8E7;
font-size: 18px;
}

.jb-form select {
border: 2px solid #97C8E7;
font-size: 18px;
}

.jb-form textarea {
border: 2px solid #97C8E7;
}
#submitButton button {
border: 0 !important;
border-radius: 0 !important;
background-color: #97C8E7 !important;
color: #000 !important;
}
.jb-form .uib-datepicker .btn,
.jb-form .uib-datepicker .btn-default .glyphicon-calendar
{
color: #000000! important
}
.jb-form.container,.container {
  padding-top: 0;
}
.container.bg-transparent.ng-scope {
  padding-bottom: 0;
}
/*-- SUBMIT BUTTON UNSELECTED --*/


/* centre position the button*/
#submitButton.btn-toolbar.center-block.margin-top-25.pull-right {
float:none!important;
position:relative;
}
#submitButton > button.btn.btn-primary.btn-lg.userBgColor {
position:absolute;
left:50%;
margin-left:-87px; /* half the width of the button*/
}
/* end center styling*/


#submitButton > button.btn.btn-primary.btn-lg.userBgColor{
    font-family: "TxX Gyre Bonum Regular";
    width: 174px;
    border-radius: 25px;
    background-color: transparent!important;
    color: #f25d03!important;
    font-weight: bold;
    border: 3px solid #f25d03!important;
    padding: 0;
    height: 45px;
    box-shadow: 1px 1px 4px rgb(0,0,0,.3);
outline:0;
transition: border-color .2s ease-in, color .2s ease-in;
}

/*-- SUBMIT BUTTON ON HOVER --*/
#submitButton > button.btn.btn-primary.btn-lg.userBgColor:hover {
border-color:#000!important;
color:#000!important;
}
.jb-form.container {
overflow:hidden /* ihde scrollbar*?}
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © finallynitin

//@version=5
indicator(title="Awesome Oscillator Trend Bar", shorttitle="AO Trend Bar", timeframe="", timeframe_gaps=true)

// Only show content if on a WEEKLY timeframe
onWeeklyChart = timeframe.isweekly

// Awesome Oscillator
ao = ta.ema(hl2,13) - ta.ema(hl2,34)
diff = ao - ao[1]

// Multi-time frame
AO_W = request.security(syminfo.tickerid, 'W', ao, lookahead=barmerge.lookahead_on)
diff_W = AO_W - AO_W[1]

AO_D = request.security(syminfo.tickerid, 'D', ao, lookahead=barmerge.lookahead_on)
diff_D = AO_D - AO_D[1]

//Conditions
longaow = AO_W >=0
longaod = AO_D >=0

shortaow = AO_W <0
shortaod = AO_D <0

//Plot
iff_1 = onWeeklyChart and shortaow and shortaod ? color.red : color.black
iff_2 = onWeeklyChart and longaow and shortaod ? color.orange : iff_1
iff_3 = onWeeklyChart and shortaow and longaod ? color.orange : iff_2
AOColor = onWeeklyChart and longaow and longaod ? color.green : iff_3

bgcolor(color=color.new(AOColor, transp = 20))
docker-compose down
docker rm -f $(docker ps -a -q)
docker volume rm $(docker volume ls -q)
docker system prune -a
x = findMax(1, 123, 500, 115, 44, 88);

function findMax() {
  var i;
  var max = -Infinity;
  for (i = 0; i < arguments.length; i++) {
    if (arguments[i] > max) {
      max = arguments[i];
    }
  }
  return max;
}
function parseFirstInt(input) {

  let inputToParse = input;

  for (let i = 0; i < input.length; i++) {
    let firstInt = parseInt(inputToParse);
    if (!Number.isNaN(firstInt)) {
      return firstInt;
    }
    inputToParse = inputToParse.substr(1);
  }

  return NaN;
}
function factorial(n) {
  if (n === 0) {
    return 1;
  }
  return factorial(n - 1) * n;
}
function reverse(str) {
  if (str === "")
    return "";
  else
    return reverse(str.substr(1)) + str.charAt(0);
}
reverse("hello");
const romanToInt = (s) => {
   const legend = "IVXLCDM";
   const l=[1,5,10,50,100,500,1000];
   let sum=0;
   while(s){
      if(!!s[1] && legend.indexOf(s[0]) < legend.indexOf(s[1])){
         sum += (l[legend.indexOf(s[1])] - l[legend.indexOf(s[0])]);
         s = s.substring(2, s.length);
      } else {
         sum += l[legend.indexOf(s[0])];
         s = s.substring(1, s.length);
      }
   }
   return sum;
};
console.log(romanToInt('CLXXVIII'));
console.log(romanToInt('LXXXIX'));
console.log(romanToInt('LV'));
console.log(romanToInt('MDLV'));
function convertToRoman(num) {

  var roman ="";

  var values = [1000,900,500,400,100,90,50,40,10,9,5,4,1];
  var literals = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"];


  for(i=0;i<values.length;i++){
    if(num>=values[i]){
      if(5<=num && num<=8) num -= 5;
      else if(1<=num && num<=3) num -= 1;
      else num -= values[i];
      roman += literals[i];
      i--;
    }
  }


 return roman;
}
star

Thu Dec 02 2021 14:15:43 GMT+0000 (Coordinated Universal Time) https://www.jscamp.app/ru/docs/javascript19/

@Evgeniya

star

Thu Dec 02 2021 14:35:58 GMT+0000 (Coordinated Universal Time) https://www.jscamp.app/ru/docs/javascript19/

@Evgeniya

star

Thu Dec 02 2021 15:07:19 GMT+0000 (Coordinated Universal Time) https://webdevblog.ru/15-poleznyh-javascript-primerov-map-reduce-i-filter/

@Evgeniya

star

Thu Dec 02 2021 15:42:54 GMT+0000 (Coordinated Universal Time) https://poopcode.com/calculate-the-average-of-an-array-of-numbers-in-javascript/

@Evgeniya

star

Thu Dec 02 2021 15:57:08 GMT+0000 (Coordinated Universal Time) https://kazupon.github.io/vue-i18n/guide/locale.html

@cecisalof

star

Thu Dec 02 2021 17:11:09 GMT+0000 (Coordinated Universal Time)

@distance

star

Thu Dec 02 2021 17:11:33 GMT+0000 (Coordinated Universal Time)

@distance

star

Thu Dec 02 2021 19:09:55 GMT+0000 (Coordinated Universal Time)

@DViorel

star

Thu Dec 02 2021 19:17:51 GMT+0000 (Coordinated Universal Time)

@DViorel

star

Thu Dec 02 2021 19:30:18 GMT+0000 (Coordinated Universal Time)

@DViorel

star

Thu Dec 02 2021 23:32:06 GMT+0000 (Coordinated Universal Time) https://forum.freecodecamp.org/t/arr-sort-a-b-a-b-explanation/167677

@tolanisirius

star

Thu Dec 02 2021 23:44:44 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/25305640/find-median-values-from-array-in-javascript-8-values-or-9-values

@tolanisirius

star

Thu Dec 02 2021 23:57:42 GMT+0000 (Coordinated Universal Time)

@MichaelTokarev

star

Fri Dec 03 2021 05:39:44 GMT+0000 (Coordinated Universal Time)

@hfwefvwefgwvef

star

Fri Dec 03 2021 07:57:25 GMT+0000 (Coordinated Universal Time)

@FaisalAfrozKhan

star

Fri Dec 03 2021 08:36:39 GMT+0000 (Coordinated Universal Time) https://askubuntu.com/questions/91598/how-do-i-login-as-root

@sazzad_sebpo

star

Fri Dec 03 2021 09:35:38 GMT+0000 (Coordinated Universal Time) https://ifaucet.ml/dashboard

@KoinSource

star

Fri Dec 03 2021 09:38:56 GMT+0000 (Coordinated Universal Time) https://icon-sets.iconify.design/

@IrtiqaMohiuddin

star

Fri Dec 03 2021 09:42:39 GMT+0000 (Coordinated Universal Time)

@sauravmanu

star

Fri Dec 03 2021 15:12:12 GMT+0000 (Coordinated Universal Time) https://www.codeproject.com/Questions/5315561/How-can-I-make-this-code-better

@tolanisirius

star

Fri Dec 03 2021 15:17:03 GMT+0000 (Coordinated Universal Time)

@finallynitin

star

Fri Dec 03 2021 16:43:34 GMT+0000 (Coordinated Universal Time) https://www.jshero.net/en/koans/factorial.html

@tolanisirius

star

Fri Dec 03 2021 17:21:24 GMT+0000 (Coordinated Universal Time)

@hfwefvwefgwvef

star

Fri Dec 03 2021 19:47:55 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/22082307/git-switch-branch-without-discarding-local-changes/22082669

@adamyalei

star

Fri Dec 03 2021 19:54:25 GMT+0000 (Coordinated Universal Time)

@pirate

star

Fri Dec 03 2021 20:24:01 GMT+0000 (Coordinated Universal Time)

@rafasacaan

star

Fri Dec 03 2021 21:00:35 GMT+0000 (Coordinated Universal Time) https://www.jshero.net/en/koans/dowhile.html

@tolanisirius

star

Fri Dec 03 2021 21:21:00 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/24144867/phpajax-passing-input-keyword-for-live-search

@khalidlogi

star

Fri Dec 03 2021 23:56:02 GMT+0000 (Coordinated Universal Time) https://learnersbucket.com/examples/algorithms/find-the-lcm-of-two-numbers-in-javascript/

@tolanisirius

star

Sat Dec 04 2021 00:19:24 GMT+0000 (Coordinated Universal Time) https://www.jshero.net/en/koans/dowhile.html

@tolanisirius

star

Sat Dec 04 2021 00:37:31 GMT+0000 (Coordinated Universal Time) https://www.jshero.net/en/koans/ggt.html

@tolanisirius

star

Sat Dec 04 2021 01:20:42 GMT+0000 (Coordinated Universal Time)

@AliArya

star

Sat Dec 04 2021 08:56:49 GMT+0000 (Coordinated Universal Time)

@ahsankhan007

star

Sat Dec 04 2021 10:08:53 GMT+0000 (Coordinated Universal Time)

@threesixnine

star

Sat Dec 04 2021 10:10:02 GMT+0000 (Coordinated Universal Time)

@threesixnine

star

Sat Dec 04 2021 10:10:33 GMT+0000 (Coordinated Universal Time)

@threesixnine

star

Sat Dec 04 2021 10:11:42 GMT+0000 (Coordinated Universal Time)

@threesixnine

star

Sat Dec 04 2021 10:13:27 GMT+0000 (Coordinated Universal Time)

@threesixnine

star

Sat Dec 04 2021 10:14:07 GMT+0000 (Coordinated Universal Time)

@threesixnine

star

Sat Dec 04 2021 10:14:35 GMT+0000 (Coordinated Universal Time)

@threesixnine

star

Sat Dec 04 2021 15:42:32 GMT+0000 (Coordinated Universal Time)

@finallynitin

star

Sat Dec 04 2021 16:49:45 GMT+0000 (Coordinated Universal Time) https://www.pexels.com/

@IrtiqaMohiuddin

star

Sat Dec 04 2021 16:53:32 GMT+0000 (Coordinated Universal Time) https://pixabay.com/

@IrtiqaMohiuddin

star

Sat Dec 04 2021 17:26:17 GMT+0000 (Coordinated Universal Time)

@igor

star

Sat Dec 04 2021 20:56:51 GMT+0000 (Coordinated Universal Time) https://newbedev.com/typescript-write-a-function-max-that-calculates-the-maximum-of-an-arbitrary-number-of-numbers-code-example

@tolanisirius

star

Sat Dec 04 2021 21:16:31 GMT+0000 (Coordinated Universal Time) https://www.jshero.net/en/koans/nan.html

@tolanisirius

star

Sat Dec 04 2021 22:41:12 GMT+0000 (Coordinated Universal Time) https://www.jshero.net/en/koans/recursion.html

@tolanisirius

star

Sat Dec 04 2021 23:40:31 GMT+0000 (Coordinated Universal Time) https://www.jshero.net/en/koans/recursion.html

@tolanisirius

star

Sat Dec 04 2021 23:55:10 GMT+0000 (Coordinated Universal Time) https://www.tutorialspoint.com/javascript-algorithm-for-converting-roman-numbers-to-decimal-numbers

@tolanisirius

star

Sun Dec 05 2021 00:00:00 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/9083037/convert-a-number-into-a-roman-numeral-in-javascript

@tolanisirius

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension