Giter Club home page Giter Club logo

011-error-regex's Introduction

011 Error Regex

Complete the reverseString function, it has one parameter s. You must perform the following actions:

  1. Try to reverse string s using the split, reverse, and join methods.
  2. If an exception is thrown, catch it and print the contents of the exception's message on a new line.
  3. Print s on new line. If no exception was thrown, then this should be the reversed string, if an exception was thrown, this should be the original string. Input Format Locked stub code in the editor reads variable s from stdin and passes it to the function. Output Format You must write two print statements using console.log():
  • Print the contents of a caught exception's message on a new line. If no exception was thrown, this line should not be printed.
  • Print s on a new line. If no exception was thrown, then this should be the reversed string, if an exception was thrown, this should be the original string.
Input
Number(1234)
Output
s.split is not a function
  • Complete the isPositive function below. It has one integer parameter a . If the value of a is positive, it must return the string YES. Otherwise, it must throw an Error according to the following rules:
  • If a is 0, throw an Error with message = Zero Error.
  • If a is negative, throw an Error with message = Negative Error.
  • Convert the code using try...catch.
function reverseString(s) {
typeOf s !== "string"
? console.log("s.split is not a function")
: (s = s.split("").reverse().join(""));
console.log(s);
}
  • A teacher has created a gradeLabs function that verifies if student programming labs work. This function loops over an array of JavaScript objects that should contain a student property and runLab property. The runLab property is expected to be a function containing the student's code. The runLab function is called and the result is compared to the expected result. If the result and expected results don't match, then the lab is considered a failure.
  • Create a RegExp myRegExp to test if a string is a valid pin or not.
  • A valid pin has:
  • Exactly 4 or 6 characters.
  • Only numerical characters (0-9).
  • No whitespace.
  • Write an expression to validate
const REGEXP = /abc/;
let str = '<> <a href="/"> <input type="radio" checked> <b>';
str.match(REGEXP);
'<a href="/">', '<input type="radio" checked>', "<b>";

011-error-regex's People

Contributors

martun-avagyan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.