Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andriikot/ruby-lesson-2-vs-js
Ruby Lesson 2 vs Js
https://github.com/andriikot/ruby-lesson-2-vs-js
Last synced: about 2 months ago
JSON representation
Ruby Lesson 2 vs Js
- Host: GitHub
- URL: https://github.com/andriikot/ruby-lesson-2-vs-js
- Owner: AndriiKot
- Created: 2023-03-21T20:30:09.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-21T20:52:54.000Z (almost 2 years ago)
- Last Synced: 2024-01-09T00:38:46.053Z (12 months ago)
- Language: Ruby
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ruby-lesson-2-vs-Js
Ruby Lesson 2 vs Js
___
```ruby
#Ruby
str = 'String 1' # "String 1"
str.size # 8
"Hello Ruby!".size # 11
str[0] # "S"
str[-1] # "1"
str[1..-1] # "tring 1"
str[1,3] # "tri"
``````node
//Js
let str = "String 1" // undefined
str // "String 1"
str.length // 8
"Hello js!".length // 9
str[0] // "S"
str[str.length - 1] // "1"
str.slice(1) // "tring 1"
str.slice(1,3) // "tr"
```
____
____
```ruby
#Ruby
joe = 'joe'
p joe.capitalize # "Joe"
p joe # "joe" !!!
joe.capitalize! # "Joe"
p joe # "Joe" !!!cat = "CAT"
cat.downcase # "cat"
p cat # "CAT" !!!
cat.downcase! # "cat"
p cat # "cat" !!!ibm = 'ibm'
ibm.upcase # "IBM"
p ibm # "ibm" !!!
ibm.upcase! # "IBM"
p ibm # "IBM"oxi = "OXI"
oxi.capitalize!
p oxi # "Oxi" !!!text = " hELo rUBY! "
text.strip!.capitalize!
p text # "Hello ruby!"
```____
```node
str.toLowerCase() // "string 1"
console.log(str) // "String 1" !!!
str.toUpperCase() // "STRING 1"
console.log(str) // "String 1" !!!let text = " hElLO jS! "
text.length // 16
text.trim()
// "hELLO jS!"
let str1 = text.toLowerCase().trim() // "hello js!"
str1 = str1[0].toUpperCase() + str1.slice(1)console.log(str1) // "Hello js!"
```